- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just went throughsome random-number generator examples (e.g.vsrnguniform.f and vsrngnegbinomial.f) included in the VSL for Fortran and noticed that all series of random numbers start with a leading zero.Why? This zero isalso included in the calculation of mean and variance. If you reduce the sample size (paramters nn and n in the example code) you can see that the mean and variancebecome highly affected by that zero. Is that a bug or is there a deeper reason? Thanks for helping!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just went throughsome random-number generator examples (e.g.vsrnguniform.f and vsrngnegbinomial.f) included in the VSL for Fortran and noticed that all series of random numbers start with a leading zero.Why? This zero isalso included in the calculation of mean and variance. If you reduce the sample size (paramters nn and n in the example code) you can see that the mean and variancebecome highly affected by that zero. Is that a bug or is there a deeper reason? Thanks for helping!
Fortran examples you listed use MCG31 BRNG which is initialized with a seed equal to 1. Some of VSL BRNGs like 31-bit multiplicate congruantial generator MCG31 or 59-bit multiplicative congruential generator MCG59 return scaled seed as the first generated random number. For this reason 1st number produced by double precision version of MCG31 BRNG in the example vdrnguniform.f is somewhat 1.0/(double)(2^31-1) that is, 4.656612875245797E-010. In order to produce first random number which is far from zero, please set seed to a different value, use another VSL BRNG, for example MT19937 or just discard first random number. Additional details regarding initialization of VSL BRNGs are available in Vslnotes.pdf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran examples you listed use MCG31 BRNG which is initialized with a seed equal to 1. Some of VSL BRNGs like 31-bit multiplicate congruantial generator MCG31 or 59-bit multiplicative congruential generator MCG59 return scaled seed as the first generated random number. For this reason 1st number produced by double precision version of MCG31 BRNG in the example vdrnguniform.f is somewhat 1.0/(double)(2^31-1) that is, 4.656612875245797E-010. In order to produce first random number which is far from zero, please set seed to a different value, use another VSL BRNG, for example MT19937 or just discard first random number. Additional details regarding initialization of VSL BRNGs are available in Vslnotes.pdf.
Thanks a lot for the fast answer! I tried seeds different from1, and up to 7 digit seeds I still get zeroes for the first random value. Then slowly the firstzero starts to change. Shouldn't there be an internal routine that takes care of that?Of course dropping the first (or more) number(s) is the best soloution, but in the following calculations in the example code the first value isn't dropped and especially forSMALL sample sizes a wrong estimator for the variance is used (assuming a vanishing covariance and dividing by n instead of n-1).
However, it's cool to have such powerfull tools for all different distributions provided in the VSL! Thanks!
Jan

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page