Can anybody shed light on this System.Random algorithm?

84 views Asked by At

Can anybody shed light on the impact of using a different value here?

CLR System.Random (random.cs, 61) appears to cite the algorithm used

//This algorithm comes from Numerical Recipes in C (2nd Ed.)

and uses this line of code (random.cs, 80)

 inextp = 21;    
 
 

However, looking at that apparent algorithm being used (Numerical Recipes in C, 283)

 inextp=31; The constant 31 is special; see Knuth.

(Knuth 124) talks about the area of distribution under a curve for random number generation being broken into 31 rectangles.

I'm no math whiz and trying to follow through this algorithm makes my brain hurt a bit.

random.cs. Microsoft Reference Source, .NET Framework 4.8 https://referencesource.microsoft.com/#mscorlib/system/random.cs

Press, Teukolsky, et. al., Numerical Recipes in C : The Art of Scientific Computing, 2nd ed. https://www.cec.uchile.cl/cinetica/pcordero/MC_libros/NumericalRecipesinC.pdf

Donald Knuth, The Art of Computer Programming 3rd ed., vol. 2 Seminumerical Alogirthms https://seriouscomputerist.atariverse.com/media/pdf/book/Art%20of%20Computer%20Programming%20-%20Volume%202%20(Seminumerical%20Algorithms).pdf

0

There are 0 answers