Ok, I really have to thanks everybody for your answers, I now understand my mistake (stupid mistake : In fact I wanted a number between 0 and 1 ....). But I have to answer some stuffs :
First I'am not trying to build my own random number generator (I know the rand() perlfunction), I'am just trying this one which is named (I also know that it is not truly random) linear congruential method. I'am trying this one, because it IS deterministic and because it is widely used for Monte Carlo simulation (I'am not trying cryptography stuffs ....).
Second, one usefull and simple test of a random generator is to break a sequence of random numbers int blocks of k numbers, which are taken to be coordinates in a k-dimensional space. A good random number should give a random distribution of points, the linear congruential method (with good parameters) seems to give good results, and I wanted to see .... (I'am gonna try it to with the rand() for fun to!)
Third : Here's the formula :
u
1=seed
u
i=MOD{(u
i-1 x a + b),m}
Fourth : Next step Marsaglia Random Number Generator !
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.