Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It shouldn't matter if there are repeats or not if there is a uniform bias in the random number generator. However most pseudo-random number generators fail this criteria (ones in practice, in theory they often pass :) ).

What I was proposing you use are sometimes called quasi-random numbers. This is because they are not really too random at all. They have a heavy bias against being chosen twice. The advantage here is that you converge faster. Additionally in the real world they will be more likely to be correct (since any unatural skew in the bias would have to be tempered with the non-repeating bias).

The reason it converges faster is because the numbers chosen are forced to not repeat, but still spread themselves evenly through a given space. I hope you can see why this would converge more quickly -- it's a tad hard to draw an ascii picture to represent this.

Basically it's like using an iteratively increasing grid (like my last post), but then you do not have to commit to any particular number of samples (with the grid, you have to do 4 the first iteration, then 5 more the next, then 10 the next, etc).

I have to be off to work, but as an example here is a base two Hamilton sequence: 0.0, 0.1, 0.01, 0.11, 0.001, 0.101, 0.011, and 0.111 . You may want to convert these numbers into decimal so you can see the sequence: 0.000, 0.500, 0.250, 0.750, 0.125, 0.625, 0.375, 0.875 . Normally, you would use a higher base (which works best when the base is also a prime number), but using 2 lets you see how it is slowly filling up a grid for you. Sobol sequences produce more random results than Hamilton, so using them is more ideal. But anyway, you get the picture.

Ciao,
Gryn


In reply to Pseudo-Random vs. Quasi-Random by gryng
in thread Pi calculator by Fingo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-06-24 05:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (123 votes). Check out past polls.

    Notices?