["tilescript", ["html", "

What is Pseudo random number generator?

"], ["html", "

\nX n+1 = (A Xn + B) mod M\n

\n

A linear congruential generator\n-- From Wikipedia, the free encyclopedia

\n

At first, define a couple of constants\nand a variable.

\n"], ["tile", "{X=0;A=13;B=5;M=24}"], ["html", "

See how numbers are made

"], ["tile", "X=(((A*X)+B)%M)"], ["source", "sequence = [];\nX = 0;\nfor (i = 0; i < 30; i++) {\n X = (A * X + B) % M;\n sequence.push(X);\n}\nsequence;"], ["html", "

Edit followed numbers and try again.

"], ["html", "
"], ["html", "
"], ["html", "
"], ["html", "
"], ["html", "Is it really a random sequence? Make sure if\nit is random with a graph.

"], ["html", "\n"], ["source", "canvas = $(\"canvas\");\nctx = canvas.getContext('2d');\nctx.clearRect(0, 0, canvas.width, canvas.height);\nctx.save();\nctx.scale(5, 5);\n// ctx.scale(1, 0.00000005);\nctx.beginPath();\nctx.moveTo(0, 0);\nfor (i = 0; i < 400; i++) {\n X = (A * X + B) % M;\n ctx.lineTo(i, X);\n}\nctx.stroke();\nctx.restore();"], ["html", "

Numerical Recipes in C advocates\na generator of the constants. Try it in\nlarger scale.

"], ["tile", "{A=1664525;B=1013904223;M=Math.pow(2,32)}"] ]