Main Page | Report this Page
 
   
Science Forum Index  »  Statistics - Math Forum  »  Goodness-of-fit test for random generators
Page 1 of 1    
Author Message
Sigbert Klinke
Posted: Mon Jan 22, 2007 4:32 am
Guest
Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

Thanks ins advance

Sigbert Klinke
John Mauer
Posted: Mon Jan 22, 2007 5:41 am
Guest
Try the KS test instead, or read Knuth for tests of RNGs. Also try
http://www.stat.fsu.edu/pub/diehard/
for a series of tests.
Old Mac User
Posted: Mon Jan 22, 2007 10:56 am
Guest
In this context Chi-sq is being used to test whether the random numbers
are uniformly distributed.
This does not tell us whether there are systematic time-series patterns
in the random numbers.
Nor does it teach us anything about some of the other properties of the
random numbers. OMU



Sigbert Klinke wrote:
Quote:
Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

Thanks ins advance

Sigbert Klinke
David Winsemius
Posted: Mon Jan 22, 2007 11:10 am
Guest
Sigbert Klinke <sigbert@wiwi.hu-berlin.de> wrote in news:ep1srh$q5$1
@hahn.informatik.hu-berlin.de:

Quote:
Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

(A non-statistician's answer:)

Appears to me that your current approach is too narrow. If you are testing
a RNG, then you should be testing at both alpha/2 and 1-alpha/2, and maybe
even other quantiles. The answer to whether to look at both extremes
depends on a proper formulation of what "should" happen. RNGs should not be
"too close" or "too far" from the theoretical result.

I am not convinced that this would be a general answer to the question of
whether to reject the null if you get a nearly predicted result and are
using a chi-square test, but I think it is fair when you are doing
simulations which have a well-characterized mathematical form.

--
David Winsemius
Marc Schwartz
Posted: Mon Jan 22, 2007 11:53 am
Guest
Sigbert Klinke wrote:
Quote:
Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

Thanks ins advance

Sigbert Klinke

As the other replies have mentioned, there are other considerations to
this issue, including the period of the RNG that you are using and the
intended application of the RNG (ie. cryptographic uses, etc.).

Some links that will provide further insight and a link to the NIST
site where there is a suite of tests available:

http://en.wikipedia.org/wiki/Pseudorandom_number_generator
http://en.wikipedia.org/wiki/Random_number_generator
http://en.wikipedia.org/wiki/Statistical_randomness
http://csrc.nist.gov/rng/

HTH,

Marc Schwartz
Gordon Sande
Posted: Mon Jan 22, 2007 12:05 pm
Guest
On 2007-01-22 11:10:42 -0400, David Winsemius <doe_snot@comcast.n0T> said:

Quote:
Sigbert Klinke <sigbert@wiwi.hu-berlin.de> wrote in news:ep1srh$q5$1
@hahn.informatik.hu-berlin.de:

Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

(A non-statistician's answer:)
Appears to me that your current approach is too narrow. If you are
testing a RNG, then you should be testing at both alpha/2 and
1-alpha/2, and maybe even other quantiles. The answer to whether to
look at both extremes depends on a proper formulation of what "should"
happen. RNGs should not be "too close" or "too far" from the
theoretical result.

I am not convinced that this would be a general answer to the question
of whether to reject the null if you get a nearly predicted result and
are using a chi-square test, but I think it is fair when you are doing
simulations which have a well-characterized mathematical form.

There is the question "The Chi^2 of what?" as there are many possible tests
of a PSEUDO random number generator. You hope that the tests you use will
allow you to have confidence that the generator will also be suitably
random for your use. Ain't always true!

In fact the good tests will repeat the sampling for the Chi^2s and ask whether
there are a suitable number of failures on both sides. Some would go so far as
to ask if the whole distriibution of the observed Chi^2s has the
predicted form.

A standard battery of tests is to have r, for resolution, bins in d dimensions
for a total of r^d cells and then test for uniformity. You will notice that
the cycle length required to support this gets very large very fast. In the
special case where you can do the number theory and you use the full cycle
this is called the spectral test. (The name is mathematically justified even
if it is not immediately the same as spectral analysis of time series.)
David A. Heiser
Posted: Mon Jan 22, 2007 9:51 pm
Guest
"Gordon Sande" <g.sande@worldnet.att.net> wrote in message
news:2007012212052016807-gsande@worldnetattnet...
Quote:
On 2007-01-22 11:10:42 -0400, David Winsemius <doe_snot@comcast.n0T> said:

Sigbert Klinke <sigbert@wiwi.hu-berlin.de> wrote in news:ep1srh$q5$1
@hahn.informatik.hu-berlin.de:

Hi,

a simple question: if I have a uniform random number generator (in
[0,1]) and I do a chi^2 goodness of fit test then I would reject the
Null hypothesis if the chi^2 value is larger than chi^2_{df;1-alpha}.
Usually I would never reject the Null hypothesis if the chi^2 value is
smaller than chi^2_{df;alpha/2} or larger than chi^2_{df;1-alpha/2}.
Could be any reason for such an approach?

(A non-statistician's answer:)
Appears to me that your current approach is too narrow. If you are
testing a RNG, then you should be testing at both alpha/2 and 1-alpha/2,
and maybe even other quantiles. The answer to whether to look at both
extremes depends on a proper formulation of what "should" happen. RNGs
should not be "too close" or "too far" from the theoretical result.

I am not convinced that this would be a general answer to the question of
whether to reject the null if you get a nearly predicted result and are
using a chi-square test, but I think it is fair when you are doing
simulations which have a well-characterized mathematical form.

There is the question "The Chi^2 of what?" as there are many possible
tests
of a PSEUDO random number generator. You hope that the tests you use will
allow you to have confidence that the generator will also be suitably
random for your use. Ain't always true!

In fact the good tests will repeat the sampling for the Chi^2s and ask
whether
there are a suitable number of failures on both sides. Some would go so
far as
to ask if the whole distriibution of the observed Chi^2s has the predicted
form.

A standard battery of tests is to have r, for resolution, bins in d
dimensions
for a total of r^d cells and then test for uniformity. You will notice
that
the cycle length required to support this gets very large very fast. In
the
special case where you can do the number theory and you use the full cycle
this is called the spectral test. (The name is mathematically justified
even
if it is not immediately the same as spectral analysis of time series.)



The tests in Knuth have to some extent have been viewed as being historic

rather than having current validity. There has been a lot of development in
RNG's since then.

Marsaglia in his diehard suite uses the Anderson-Darling test for
uniformity. The narrative/description is wrong on this. He prefers the AD
test, since it emphasizes the ends of the distribution.

My work with RNG's has indicated that trying to prove/demonstrate uniformity
is a real bear. To attain uniformity at the upper and lower ends one has to
get strings of zeros and ones, which either can't be generated, or the RNG
has been "tailored" to block these as outputs. The second problem is that
results from RNG tests are like the RNGs themselves, highly variable. One
expert says, just one case of failing uniformity is cause to reject the RNG.
Another expert says no. You have to look at repeats of the test. Each
different uniformity test will also give different p values.

RNGs are like automobiles. They have new models each year. Users love to
tinker with them. Users make extravagant claims about their "automobile" and
their "RNG" as being the best in the world. It has to do with color, drive
and feel.

David Heiser
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Mon Sep 08, 2008 12:11 pm