gov.sandia.cognition.statistics.distribution
Class StudentizedRangeDistribution

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.statistics.AbstractDistribution<NumberType>
          extended by gov.sandia.cognition.statistics.AbstractClosedFormUnivariateDistribution<Double>
              extended by gov.sandia.cognition.statistics.distribution.StudentizedRangeDistribution
All Implemented Interfaces:
Vectorizable, ClosedFormDistribution<Double>, ClosedFormUnivariateDistribution<Double>, Distribution<Double>, DistributionWithMean<Double>, UnivariateDistribution<Double>, CloneableSerializable, Randomized, Serializable, Cloneable
Direct Known Subclasses:
StudentizedRangeDistribution.CDF

@PublicationReferences(references={@PublicationReference(author="David M. Lane",title="Studentized Range Distribution",type=WebPage,year=2011,url="http://davidmlane.com/hyperstat/A47912.html"),@PublicationReference(author="Wikipedia",title="Studentized range",type=WebPage,year=2011,url="http://en.wikipedia.org/wiki/Studentized_range")})
public class StudentizedRangeDistribution
extends AbstractClosedFormUnivariateDistribution<Double>
implements Randomized

Implementation of the Studentized Range distribution, which defines the population correction factor when performing multiple comparisons. In other words, if you compute the p-value of 20 objects, there's a 65% chance of finding at least one with a p-value of less than 0.05. The Studentized Range compensates for this chance when conducting multiple comparisons.

Since:
3.1
Author:
Kevin R. Dixon
See Also:
Serialized Form

Nested Class Summary
static class StudentizedRangeDistribution.APStat
          This is a translation of Fortran code taken from http://lib.stat.cmu.edu/apstat/, and the comments on the individual functions in this class are taken directly from the original.
static class StudentizedRangeDistribution.CDF
          CDF of the StudentizedRangeDistribution
protected static class StudentizedRangeDistribution.SampleRange
          Computes the estimate of the Studentized Range for a single sample
 
Field Summary
static double DEFAULT_DEGREES_OF_FREEDOM
          Default degrees of freedom, 1d/0d.
static int DEFAULT_NUM_SAMPLES
          Number of samples to draw for Monte Carlo estimates, 1000.
static int DEFAULT_TREATMENT_COUNT
          Default treatment count, 2.
protected  double degreesOfFreedom
          Number of subjects in each treatment minus one.
protected  Random random
          Random number generator for Monte Carlo simulations
protected  int treatmentCount
          Number of comparisons made
 
Constructor Summary
StudentizedRangeDistribution()
          Default constructor
StudentizedRangeDistribution(int treatmentCount, double degreesOfFreedom)
          Creates a new instance of StudentizedRangeDistribution
StudentizedRangeDistribution(StudentizedRangeDistribution other)
          Copy constructor
 
Method Summary
 StudentizedRangeDistribution clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts the object from a Vector of parameters.
 Vector convertToVector()
          Converts the object to a vector.
 StudentizedRangeDistribution.CDF getCDF()
          Gets the CDF of a scalar distribution.
 double getDegreesOfFreedom()
          Getter for degreesOfFreedom
 Double getMaxSupport()
          Gets the minimum support (domain or input) of the distribution.
 Double getMean()
          Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.
 Double getMinSupport()
          Gets the minimum support (domain or input) of the distribution.
 Random getRandom()
          Gets the random number generator used by this object.
 int getTreatmentCount()
          Getter for treatmentCount
 double getVariance()
          Gets the variance of the distribution.
 ArrayList<Double> sample(Random random, int numSamples)
          Draws multiple random samples from the distribution.
 void setDegreesOfFreedom(double degreesOfFreedom)
          Setter for degreesOfFreedom
 void setRandom(Random random)
          Sets the random number generator used by this object.
 void setTreatmentCount(int treatmentCount)
          Setter for treatmentCount
 
Methods inherited from class gov.sandia.cognition.statistics.AbstractDistribution
sample
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.statistics.Distribution
sample
 

Field Detail

DEFAULT_TREATMENT_COUNT

public static final int DEFAULT_TREATMENT_COUNT
Default treatment count, 2.

See Also:
Constant Field Values

DEFAULT_DEGREES_OF_FREEDOM

public static final double DEFAULT_DEGREES_OF_FREEDOM
Default degrees of freedom, 1d/0d.

See Also:
Constant Field Values

DEFAULT_NUM_SAMPLES

public static final int DEFAULT_NUM_SAMPLES
Number of samples to draw for Monte Carlo estimates, 1000.

See Also:
Constant Field Values

treatmentCount

protected int treatmentCount
Number of comparisons made


degreesOfFreedom

protected double degreesOfFreedom
Number of subjects in each treatment minus one.


random

protected Random random
Random number generator for Monte Carlo simulations

Constructor Detail

StudentizedRangeDistribution

public StudentizedRangeDistribution()
Default constructor


StudentizedRangeDistribution

public StudentizedRangeDistribution(int treatmentCount,
                                    double degreesOfFreedom)
Creates a new instance of StudentizedRangeDistribution

Parameters:
treatmentCount - Number of comparisons made
degreesOfFreedom - Number of subjects in each treatment minus one.

StudentizedRangeDistribution

public StudentizedRangeDistribution(StudentizedRangeDistribution other)
Copy constructor

Parameters:
other - StudentizedRangeDistribution to copy
Method Detail

clone

public StudentizedRangeDistribution clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractClosedFormUnivariateDistribution<Double>
Returns:
A clone of this object.

sample

public ArrayList<Double> sample(Random random,
                                int numSamples)
Description copied from interface: Distribution
Draws multiple random samples from the distribution. It is generally more efficient to use this multiple-sample method than multiple calls of the single-sample method. (But not always.)

Specified by:
sample in interface Distribution<Double>
Parameters:
random - Random-number generator to use in order to generate random numbers.
numSamples - Number of samples to draw from the distribution.
Returns:
Samples drawn according to this distribution.

getCDF

public StudentizedRangeDistribution.CDF getCDF()
Description copied from interface: UnivariateDistribution
Gets the CDF of a scalar distribution.

Specified by:
getCDF in interface ClosedFormUnivariateDistribution<Double>
Specified by:
getCDF in interface UnivariateDistribution<Double>
Returns:
CDF of the scalar distribution.

getMean

public Double getMean()
Description copied from interface: DistributionWithMean
Gets the arithmetic mean, or "first central moment" or "expectation", of the distribution.

Specified by:
getMean in interface DistributionWithMean<Double>
Returns:
Mean of the distribution.

convertToVector

public Vector convertToVector()
Description copied from interface: Vectorizable
Converts the object to a vector.

Specified by:
convertToVector in interface Vectorizable
Returns:
The Vector form of the object.

convertFromVector

public void convertFromVector(Vector parameters)
Description copied from interface: Vectorizable
Converts the object from a Vector of parameters.

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - The parameters to incorporate.

getMinSupport

public Double getMinSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMinSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getMaxSupport

public Double getMaxSupport()
Description copied from interface: UnivariateDistribution
Gets the minimum support (domain or input) of the distribution.

Specified by:
getMaxSupport in interface UnivariateDistribution<Double>
Returns:
Minimum support.

getVariance

public double getVariance()
Description copied from interface: UnivariateDistribution
Gets the variance of the distribution. This is sometimes called the second central moment by more pedantic people, which is equivalent to the square of the standard deviation.

Specified by:
getVariance in interface UnivariateDistribution<Double>
Returns:
Variance of the distribution.

getTreatmentCount

public int getTreatmentCount()
Getter for treatmentCount

Returns:
Number of comparisons made

setTreatmentCount

public void setTreatmentCount(int treatmentCount)
Setter for treatmentCount

Parameters:
treatmentCount - Number of comparisons made

getDegreesOfFreedom

public double getDegreesOfFreedom()
Getter for degreesOfFreedom

Returns:
Number of subjects in each treatment minus one.

setDegreesOfFreedom

public void setDegreesOfFreedom(double degreesOfFreedom)
Setter for degreesOfFreedom

Parameters:
degreesOfFreedom - Number of subjects in each treatment minus one.

getRandom

public Random getRandom()
Description copied from interface: Randomized
Gets the random number generator used by this object.

Specified by:
getRandom in interface Randomized
Returns:
The random number generator used by this object.

setRandom

public void setRandom(Random random)
Description copied from interface: Randomized
Sets the random number generator used by this object.

Specified by:
setRandom in interface Randomized
Parameters:
random - The random number generator for this object to use.