Java Statistical Classes

jsc.onesample
Class Ztest

java.lang.Object
  |
  +--jsc.onesample.Ztest
All Implemented Interfaces:
SignificanceTest

public class Ztest
extends Object
implements SignificanceTest

This class represents a z-test for the mean of a distribution. It performs a significance test of the mean when the population standard deviation, sigma, is known. This procedure is based on the normal distribution. From the Central Limit Theorem, this test can be used if the sample is large (say > 30), substituting the sample standard deviation for sigma. Note that the corresponding confidence interval is provided by class LargeSampleMeanCI.

Version:
1.0
Author:
A. J. Bertie.

Constructor Summary
Ztest(double[] x, double mu)
          Create significance test results.
Ztest(double[] x, double mu, double sigma)
          Create significance test results.
Ztest(double[] x, double mu, double sigma, H1 alternative)
          Create significance test results.
Ztest(double[] x, double mu, H1 alternative)
          Create significance test results.
 
Method Summary
 double getMean()
          Returns sample mean.
 double getSd()
          Returns sample standard deviation.
 double getSP()
          Returns the value of the significance probability.
static double getSP(double z, H1 alternative)
          Calculate the significance probability.
 double getTestStatistic()
          Returns value of test statistic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ztest

public Ztest(double[] x,
             double mu,
             double sigma,
             H1 alternative)
Create significance test results.

Parameters:
x - the sample data.
mu - the value of the mean under the null hypothesis.
sigma - the standard deviation of the population.
alternative - code indicating the alternative hypothesis: LESS_THAN, NOT_EQUAL, or GREATER_THAN.

Ztest

public Ztest(double[] x,
             double mu,
             double sigma)
Create significance test results. The alternative hypothesis is NOT_EQUAL.

Parameters:
x - the sample data.
mu - the value of the mean under the null hypothesis.
sigma - the standard deviation of the population.

Ztest

public Ztest(double[] x,
             double mu,
             H1 alternative)
Create significance test results. The standard deviation of the population is estimated by the sample standard deviation

Parameters:
x - the sample data.
mu - the value of the mean under the null hypothesis.
alternative - code indicating the alternative hypothesis: LESS_THAN, NOT_EQUAL, or GREATER_THAN.

Ztest

public Ztest(double[] x,
             double mu)
Create significance test results. The standard deviation of the population is estimated by the sample standard deviation The alternative hypothesis is NOT_EQUAL.

Parameters:
x - the sample data.
mu - the value of the mean under the null hypothesis.
Method Detail

getMean

public double getMean()
Returns sample mean.

Returns:
the mean of the sample.

getSd

public double getSd()
Returns sample standard deviation.

Returns:
the standard deviation of the sample.

getSP

public double getSP()
Description copied from interface: SignificanceTest
Returns the value of the significance probability.

Specified by:
getSP in interface SignificanceTest
Returns:
the value of the significance probability.

getSP

public static double getSP(double z,
                           H1 alternative)
Calculate the significance probability. Given statistic z from the standard normal distribution, returns the appropriate tail probability for the given alternative hypothesis.

Parameters:
z - the z-test statistic.
alternative - code indicating the alternative hypothesis: LESS_THAN, NOT_EQUAL, or GREATER_THAN.
Returns:
the significance probability.

getTestStatistic

public double getTestStatistic()
Returns value of test statistic.

Specified by:
getTestStatistic in interface SignificanceTest
Returns:
the value of z.

Java Statistical Classes

Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005