public class Chi2Test extends Object
This class is used to test the distribution of series of numbers such hashes and (pseudo) random numbers.
assume that you want to test a function f() which returns a number between 0 and N-1:
Chi2Test c2t = new Chi2Test(N);
while(c2t.more()) c2t.add( f() );
if(c2t.isChi2Acceptable())
System.out.println("The distribution of f() is random enough for me!");
| Constructor and Description |
|---|
Chi2Test(int n)
start a chi^2 for the input numbers 0..n-1
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int x)
add a new number.
|
double |
getChi2()
get the chi2 value.
|
int[] |
getDistibution()
Get the distribution vector
|
double |
getStandardDeviation()
get the standard deviation.
|
boolean |
isChi2Acceptable()
"Acceptable" does not mean good.
|
boolean |
isStandardDeviationAcceptable()
"Acceptable" does not mean good.
|
static void |
main(String[] args) |
boolean |
more()
returns true if it has enough samples to give an accurate answer.
|
void |
reset()
reset the chi^2, start all over
|
public Chi2Test(int n)
n must be larger than 20. don't make it too large unless you have enough memory for it.
Also, if n is too small (say bellow 1000), then you might get many false answers so instead consider the majority of multiple runs.
public void reset()
public boolean more()
NOTE: most other functions here cannot be called before this functions starts returning falsees!
public void add(int x)
more()public double getChi2()
public double getStandardDeviation()
public boolean isChi2Acceptable()
isStandardDeviationAcceptable(),
getChi2()public boolean isStandardDeviationAcceptable()
isChi2Acceptable(),
getStandardDeviation()public int[] getDistibution()
public static void main(String[] args)
This file is a part of the JDD package, a native Java Binary Decision Diagram Library.