The trouble is all inside your head, she said to me.  The answer it easy-if you 
take it logically.

It is human nature to remember patterns, so no matter how wonderful your sort 
routine is folks is still going to call the program a yellow dog lying cur.  I 
forget the term for it, but is something reinforcement.  



Austin Nichols <[EMAIL PROTECTED]> wrote:                                  
Graham--
 I realize this list is about half programming and half feature/help
 requests, but I'm hoping you can elaborate on this comment for the
 half-programmers on the list...  I think you're saying that a "bad"
 pseudo-random number generator (PRNG) might be, say, slightly more
 likely to pick a Q on the first draw than the expected 1/100, or, more
 interestingly perhaps, slightly more likely to pick an exchanged tile
 on the next draw, say, and you suggest a shuffling procedure where you
 reorder individual elements in a vanishingly small proportion based on
 the probability of drawing an endpoint--but the shuffling procedure
 you describe is a bit obscure to me, so I might be completely missing
 your point...
 
 On 9/12/07, Graham Toal <[EMAIL PROTECTED]> wrote:
 > On 9/12/07, jasonkatzbrown <[EMAIL PROTECTED]> wrote:
 > > I'm surprised you would ask, even out of jest, but tiles are drawn as
 > > pseudo-randomly as they need to be. If you want to further
 > > investigate, all tile drawing goes through this one function that
 > > draws one letter from the bag:
 > >
 > > [bag.cpp]
 > >
 > > Letter Bag::pluck()
 > > {
 > > return erase(DataManager::self()->randomNumber() % m_tiles.size());
 > > }
 >
 > You're probably aware that there is a *slight* bias in that code
 > (consider the degenerate case of a random number generator that
 > returned a value in the range 0..7, and you wanted to pick a die face
 > in the range 0..5 - then the values 6 and 7 would map to 0 and 1,
 > making them twice as likely to turn up.  However since the PRNG range
 > is probably 32 bits (or at worst 16) then the extra probability of the
 > end cases is vanishingly small.
 >
 > However, to ensure a fair distribution no matter how bad the PRNG, a
 > better algorithm is to use the card shuffling trick once at startup,
 > and then take the tiles sequentially from the shuffled list.  (The
 > shuffling alg is to go down the list one by one, swapping the current
 > element with the last element if a random function in the range 0..1
 > is 0.  Then for added safety, create that random function by exoring
 > *all* the bits from your PRNG down to a single bit, in case you have a
 > bad PRNG with a bias at one end or the other.
 >
 > regards
 >
 > Graham
 >
 >
 >
 > Yahoo! Groups Links
 >
 >
 >
 >
 
     
                       

Reply via email to