org.statcato.statistics.inferential.nonparametrics
Class RunsTest

java.lang.Object
  extended by org.statcato.statistics.inferential.nonparametrics.RunsTest

public class RunsTest
extends java.lang.Object

Runs test for randomness. A nonparametic test that the number of runs (sequence of data having the same characteristic) in a sequence of sample data to test for randomness in the order of the data.

Since:
1.0
Version:
%I%, %G%
Author:
Margaret Yau

Constructor Summary
RunsTest(int n1, int n2, int G, double significance)
          Constructor, given summarized data.
RunsTest(java.util.Vector<Cell> vector, java.lang.String cat1, java.lang.String cat2, double significance)
          Constructor, given a vector of Cell containing data of two categories, the two categories, and significance level.
RunsTest(java.util.Vector<java.lang.Double> vector, double separator, double significance)
          Constructor, given a vector containing numerical data, a separator value, and the significance.
 
Method Summary
 double criticalValue()
           
 double mu()
          Returns the mean of the distribution of runs, mu = 2 * n1 * n2 / (n1 + n2) + 1.
 double pValue()
          Returns the p-value.
 double sigma()
          Returns the standard deviation of the distribution of runs, sigma = [(2 * n1 * n2)(2 * n1 * n2 - n1 - n2) / (n1 + n2)^2 / (n1 + n2 - 1)]^0.5
 double testStatistic()
          Returns the test statistic z = (G - mu) / sigma, where G is the number of runs, mu the mean of the distribution of runs, and sigma the standard deviatioin of the distribution of runs.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RunsTest

public RunsTest(int n1,
                int n2,
                int G,
                double significance)
Constructor, given summarized data.

Parameters:
n1 - number of category 1
n2 - number of category 2
G - number of runs
significance - significance level

RunsTest

public RunsTest(java.util.Vector<Cell> vector,
                java.lang.String cat1,
                java.lang.String cat2,
                double significance)
Constructor, given a vector of Cell containing data of two categories, the two categories, and significance level.

Parameters:
vector - vector of Cell
cat1 - string representing category 1
cat2 - string representing category 2
significance - significance level

RunsTest

public RunsTest(java.util.Vector<java.lang.Double> vector,
                double separator,
                double significance)
Constructor, given a vector containing numerical data, a separator value, and the significance. Test for randomness in which the numerical data fluctuates above or below the separator. Values equal to the separator are ignored.

Parameters:
vector - vector of double values
separator - double value separating the two groups
significance - significance level
Method Detail

testStatistic

public double testStatistic()
Returns the test statistic z = (G - mu) / sigma, where G is the number of runs, mu the mean of the distribution of runs, and sigma the standard deviatioin of the distribution of runs.

Returns:
test statistic z

mu

public double mu()
Returns the mean of the distribution of runs, mu = 2 * n1 * n2 / (n1 + n2) + 1.

Returns:
mean

sigma

public double sigma()
Returns the standard deviation of the distribution of runs, sigma = [(2 * n1 * n2)(2 * n1 * n2 - n1 - n2) / (n1 + n2)^2 / (n1 + n2 - 1)]^0.5

Returns:
standard deviation

pValue

public double pValue()
Returns the p-value.

Returns:
p-value

criticalValue

public double criticalValue()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object