Linear Congruential Generators, Bays-Durham Shuffle

  • Thread starter Thread starter koenigcochran
  • Start date Start date
  • Tags Tags
    Generators Linear
Click For Summary

Discussion Overview

The discussion revolves around the Bays-Durham Shuffle as a method to improve the performance of Linear Congruential Generators (LCGs) by reducing low-order correlations. Participants seek clarification on the algorithm and share their implementations and observations regarding its effectiveness.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants express confusion regarding the algorithm's description in literature and seek a clearer summary.
  • One participant outlines a procedure for implementing the Bays-Durham Shuffle, detailing the creation of a table from an LCG and the process of generating an output stream.
  • Another participant appreciates the illustrations provided and notes that terminology differences may contribute to their confusion.
  • Questions arise about the final output of the algorithm, specifically whether it consists of the output stream, the table, or both, and whether the length of the table affects the results.
  • One participant reports discrepancies between their implementation of the Bays-Durham algorithm and the expected results, noting differences in the randomness of the output compared to a reference plot.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the effectiveness of their implementations or the specifics of the Bays-Durham Shuffle algorithm. Multiple viewpoints and uncertainties about the algorithm's details and outcomes persist.

Contextual Notes

Participants mention specific parameters such as initial seeds and divisors, but there is no agreement on optimal values or the implications of different table lengths. Some implementations may not align with established references, leading to further questions about correctness.

koenigcochran
Messages
15
Reaction score
0
Hi!

I've got an idea of how LCGs work. However, I'm reading "Exploring Monte Carlo Methods" and came across the Bays-Durham Shuffle, a means of getting rid of low-order correlations in the minimal standard LCG.

The outline of this algorithm in the book makes no sense to me. Can someone summarize the algorithm?
 
Technology news on Phys.org
koenigcochran said:
Hi!

I've got an idea of how LCGs work. However, I'm reading "Exploring Monte Carlo Methods" and came across the Bays-Durham Shuffle, a means of getting rid of low-order correlations in the minimal standard LCG.

The outline of this algorithm in the book makes no sense to me. Can someone summarize the algorithm?

I don't know if this is any improvement on what you read, but ...

Create the table of length k from an Linear Congruential Generator (LCG). Continue the LCG to create a stream S of length n. Initialize RNG output stream to first element (13 in this case) of S, then repeat following until output stream has n elements ..
  • get next number s from S
  • form the index j into the table (j = s mod k)
  • get jth element of table and add it to the output stream
  • replace jth element of table with s

Here's Mathcad-produced list of the a 5-number sequence:


And the algorithm ...

The worksheet is attached (unless it's too big!)
 

Attachments

  • phys - 12 05 31 Bays Durham Shuffle 02.jpg
    phys - 12 05 31 Bays Durham Shuffle 02.jpg
    26.2 KB · Views: 760
  • phys - 12 05 31 Bays Durham Shuffle 01.jpg
    phys - 12 05 31 Bays Durham Shuffle 01.jpg
    38.3 KB · Views: 671
  • phys = 12 05 31 Bays Durham 01.mcd
    phys = 12 05 31 Bays Durham 01.mcd
    39.2 KB · Views: 498
Three things

(1) The illustration of the table and output stream were very helpful; thank you so much! I think its the diction that has confused me--I would describe the algorithm with a choice of words totally different from what I've found in literature (probably just a consequence of my background).
(2) Did you use an initial seed 8 and divisor 30 in the image of the table and output stream? I'd like to check my own implementation of the shuffle.
(3) For your name's sake, I hope you've seen "Little Nemo: Adventures in Slumberland." A trippy, childhood favorite.

Thanks again!
 
Also:

Is the final vector of 'random' numbers the appendage of the output stream to the table? Just the table? Just the output stream? Or does it matter?

Thanks Nemo.
 
Disregard that last question, I've answered it for myself. The output stream is of arbitrary length and should be used as the vector of 'random' numbers.

However the question remains: does the length of the table matter? Is there an optimal length?
 
koenigcochran said:
Three things

(1) The illustration of the table and output stream were very helpful; thank you so much! I think its the diction that has confused me--I would describe the algorithm with a choice of words totally different from what I've found in literature (probably just a consequence of my background).
(2) Did you use an initial seed 8 and divisor 30 in the image of the table and output stream? I'd like to check my own implementation of the shuffle.

No, I used an initial seed of 9. The '8' is the length of the 'shuffle' table and '30' is the length of the output vector. What you wouldn't have seen without Mathcad is the first half of the worksheet containing the LCG. See attached, the LCG agrees with the sequence given in Gentle.

(3) For your name's sake, I hope you've seen "Little Nemo: Adventures in Slumberland." A trippy, childhood favorite.
Nope, but my children probably have. My name's more to do with the Latin I studied at school.

Thanks again!
No problem.
 

Attachments

  • phys - 12 06 01 Bays Durham Shuffle 01.jpg
    phys - 12 06 01 Bays Durham Shuffle 01.jpg
    36.3 KB · Views: 678
koenigcochran said:
I'd like to check my own implementation of the shuffle.
I'm reasonably certain that my LCG implementation is correct (or I've made the same mistake as the original implementation!), however, I'm not so sure about the Bays-Durham algorithm. The initial 3 numbers agree with those given by Gentle, but the plot of successive pairs is completely different. I can see a pattern of sorts in Gentle's plot but mine appears to be far more random, even in the 3D version (it's really interesting to compare the 'before' and 'after' shuffle plots). So, there is a possibility that I'm either plotting the data incorrectly and/or I've made an error in the implementation that doesn't show up until later in the sequence. I've had a brief webtrawl but can't find anything better to check against at the moment.

NR
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 2 ·
Replies
2
Views
625
Replies
3
Views
3K
  • · Replies 75 ·
3
Replies
75
Views
13K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 16 ·
Replies
16
Views
7K