Re: Interesting

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Dave O. wrote:
"dpb" <none@xxxxxxx> wrote in message news:fga7uu$mq7$1@xxxxxxxxxxx

The most fundamental issue in any simulation is the verification of the RNG, and the VB generator is an example of one of the worst types as reading any of the references supplied will demonstrate.

The first two large scale (~100m "lines") runs I made vindicated your assertion vividly, so I have been sidetracked into looking into RNGs and very interesting it is too. As I don't have the bits around to count radioactive decay (which I believe to be about as good as it gets for RNG) I'll have to look at mathematical trickery.
The problem as I see it is not the spread of the numbers generated as plotting several million numbers from the VB RNG gives a reasonably flat and even plot, the bigger issue is the cyclic nature of the VB RNG which means on the huge runs which may require the generation of more then 0.5billion random numbers the results from subsequent runs are just too similar although the average is pretty much what you'd expect.

So I'll be looking into and experimenting with RNGs for a while.

First, it was not "my" assertion; I only reported on results of research on pseudo-rng's quality in general that happen to include VB's in particular.

The period is certainly one problem, but far from the most fundamental. Have you read the paper by L'Ecuyer I gave you the link to yet? If not, it should be your next step. Here's a separate link to it in its pdf version that is a little easier on the eyes--the other link was the auto-generated html page which load quicker but isn't as pretty...

SOFTWARE FOR UNIFORM RANDOM NUMBER GENERATION:
DISTINGUISHING THE GOOD AND THE BAD
Pierre L’Ecuyer

http://www.informs-sim.org/wsc01papers/012.PDF

If you're really serious about any simulation, that is mandatory to have at least a conceptual idea of the issues. But, once you get a grasp on the fact there are bad ones to be avoided, it's kinda' like cars -- you don't have to be a gee-whiz engine mechanic to drive one adequately.

Simply plotting numbers and looking at whether the result is "a reasonably flat and even plot" doesn't come even close to providing a basis for assessing the quality of a prng for anything other than the grossest of uses for toy games or somesuch.

I also previously posted a link to some of George Marsaglia's work and in particular look at the Diehard test suite at http://stat.fsu.edu/pub/diehard/

In addition, I also previously posted a link to the source for Dr Marsaglia's "KISS" generator which has a period of something like 2^123 and does well on his battery of tests.

It, however, is sufficiently short that I'll paste the code here. If I get motivated and have some extra time, I might possibly look at what it would take to translate it to native VB, but for my own use I would simply call it directly. I might also be persuaded to compile it to a DLL if you don't have an F95 compiler installed and were to ask (nicely :) )...

module marsaglia
implicit none
private
public :: kiss, kisset
INTEGER :: x=123456789, y=362436069, z=521288629, w=916191069
contains
FUNCTION kiss ()
integer :: kiss
! The KISS (Keep It Simple Stupid) random number generator. Combines:
! (1) The congruential generator x(n)=69069*x(n-1)+1327217885,
! period 2^32.
! (2) A 3-shift shift-register generator, period 2^32-1,
! (3) Two 16-bit multiply-with-carry generators,
! period 597273182964842497>2^59
! Overall period>2^123; Default seeds x,y,z,w.
! Set your own seeds with statement i=kisset(ix,iy,iz,iw).
!
x = 69069 * x + 1327217885
y = m (m (m (y, 13), - 17), 5)
z = 18000 * iand (z, 65535) + ishft (z, - 16)
w = 30903 * iand (w, 65535) + ishft (w, - 16)
kiss = x + y + ishft (z, 16) + w
contains
function m(k, n)
integer :: m, k, n
m = ieor (k, ishft (k, n) )
end function m
END FUNCTION kiss

function kisset (ix, iy, iz, iw)
integer :: kisset, ix, iy, iz, iw
x = ix
y = iy
z = iz
w = iw
kisset = 1
end function kisset
end module marsaglia

PROGRAM test
use marsaglia
PRINT *, kiss ()
PRINT *, kisset (1, 2, 3, 4)
PRINT *, kiss ()
END PROGRAM test

This shouldn't be at all hard to read for a VB'er -- I'll only note that Fortran Integer --> VB Long

Implementation might be somewhat of a trick, I don't know -- I've not even considered it in reality so far.

As for the comment on radioactive decay bits and mathematical trickery, I'll simply quote a short section from Dr Marsaglia's intro to the contents of his Diehard CD...

"This CDROM contains 4.8 billion random bits ... They are a
combination of some of the best deterministic random number generators with three
commercial devices that claim to produce true randomness. There are
three ... files of typical output from those devices [but] They fail to
meet the stringent requirements of DIEHARD: a battery of tests
of randomness, files for which are also included on this CDROM.

But the sixty 10-meg files bit.01,...,bit.60 seem to pass all tests of
randomness and independence, and they are offered here as a source for
those doing serious Monte Carlo work, who absolutely positively have to
have a reliable source of random bits."

And

Instructions for using DIEHARD: a battery of tests of randomness.

I hope you will inform me of results, good or bad, of new kinds
of generators you have tested, particularly deterministic
generators, but also the output of physical devices.
(I have found none of the latter that get past DIEHARD,
and would like to learn of any that do.)

Since, in my opinion, there is no true randomness,
collective experience in finding sequences that depart from
the theoretical ideal in a significant way can perhaps lead
to better ways for finding those that do not.
....
Addendum: You will also find a postscript file mwc1.ps that, when
processed, describes what I think are the RNG's of the future:
multiply-with-carry. You will find they pass all tests, have very
long periods and are particularly well suited for computer implementation.

The above quotes are taken from the documentation for the Diehard suite
file which you can link to from the above link at FSU.

Finally a word for all of those who refuse to even consider running their own simulations because they KNOW they are right. If everybody always had that attitude we would have no electronics at all. Whilst I am no Dirac or Heisenberg their work on QM which Einstein roundly condemned flies completely in the face of classical mathematics. If back then everybody had said "I know this is wrong so I need not investigate" we would still be using slide rules and Morse code.

Your characterization here is also wrong -- indeed, while Einstein did not "like" the implications of the uncertainty principle, he certainly recognized the success with QM explained the many non-classical physics problems of the day. In fact, it was his work that opened the door to Pandora's box (so to speak) by his radical explanation of the photoelectric effect that set off the whole thing, fundamentally. He was simply convinced there had to be other avenues mathematically to approach the problem that did not rely on the Dirac/Heisenberg formulation that could still produce results consonant with experiment.

You're trying to make the leap that that is the same thing as if Einstein rejected the results of the experimental work which quantum mechanics was able to explain--a similar leap as what you made regarding the set of "regular" numbers being somehow different despite the postulate of a fair drawing. The conclusion simply does not follow from the premise.

In all, I think you have bitten off a far larger task than you seem to yet recognize.

--
.



Relevant Pages

  • Re: largely OT: a random-number generator and bzip2
    ... >> generators, and I add their results to generate the ... because they each have the same cycle individually. ... as for the knuth rng, ... or is the point that the algo will only have a single cycle this ...
    (comp.compression)
  • Re: Random Number Generation -----> Hardware or Software?
    ... But these are NOT true random number generators. ... > from the algorithm and the seed. ... then perhaps a "real" rng isn't suitable. ... encryption keys for successive data transmissions. ...
    (comp.arch.embedded)
  • Re: Question about random number generation
    ... What is NR RNG ?? ... I assume this means "Numerical Recipes Random Number Generators". ...
    (sci.stat.math)
  • Re: random numbers generator in hardware
    ... your RNG produces its bits or how they are processed. ... true random number generators are very hard to achieve, ... How do you determine the actual entropy generation rate? ...
    (sci.crypt)
  • Re: random .. ?
    ... > Cristiano wrote: ... >> generators. ... DIEHARD is not very useful for testing 32-bit PRGs. ...
    (sci.crypt)