Click or drag to resize
Accord.NET (logo)

ZTest Class

One-sample Z-Test (location test).
Inheritance Hierarchy
SystemObject
  Accord.Statistics.TestingHypothesisTestNormalDistribution
    Accord.Statistics.TestingZTest
      Accord.Statistics.TestingKappaTest
      Accord.Statistics.TestingReceiverOperatingCurveTest
      Accord.Statistics.TestingWaldTest

Namespace:  Accord.Statistics.Testing
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class ZTest : HypothesisTest<NormalDistribution>
Request Example View Source

The ZTest type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAnalysis
Gets the power analysis for the test, if available.
Public propertyConfidence
Gets the 95% confidence interval for the EstimatedValue.
Public propertyCriticalValue
Gets the critical value for the current significance level.
(Inherited from HypothesisTestTDistribution.)
Public propertyEstimatedValue
Gets the estimated value, such as the mean estimated from a sample.
Public propertyHypothesis
Gets the alternative hypothesis under test. If the test is Significant, the null hypothesis can be rejected in favor of this alternative hypothesis.
Public propertyHypothesizedValue
Gets the hypothesized value.
Public propertyPValue
Gets the P-value associated with this test.
(Inherited from HypothesisTestTDistribution.)
Public propertySignificant
Gets whether the null hypothesis should be rejected.
(Inherited from HypothesisTestTDistribution.)
Public propertySize
Gets the significance level for the test. Default value is 0.05 (5%).
(Inherited from HypothesisTestTDistribution.)
Public propertyStandardError
Gets the standard error of the estimated value.
Public propertyStatistic
Gets the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyStatisticDistribution
Gets the distribution associated with the test statistic.
(Inherited from HypothesisTestTDistribution.)
Public propertyTail
Gets the test type.
(Inherited from HypothesisTestTDistribution.)
Top
Methods
  NameDescription
Protected methodCompute(Double, OneSampleHypothesis)
Computes the Z test.
Protected methodCompute(Double, Double, Double, OneSampleHypothesis)
Computes the Z test.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetConfidenceInterval
Gets a confidence interval for the EstimatedValue statistic within the given confidence level percentage.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnSizeChanged
Update event.
(Overrides HypothesisTestTDistributionOnSizeChanged.)
Public methodPValueToStatistic(Double)
Converts a given p-value to a test statistic.
(Overrides HypothesisTestTDistributionPValueToStatistic(Double).)
Public methodStatic memberPValueToStatistic(Double, DistributionTail)
Converts a given p-value to a test statistic.
Public methodStatisticToPValue(Double)
Converts a given test statistic to a p-value.
(Overrides HypothesisTestTDistributionStatisticToPValue(Double).)
Public methodStatic memberStatisticToPValue(Double, DistributionTail)
Converts a given test statistic to a p-value.
Public methodToString
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Public methodToString(String, IFormatProvider)
Converts the numeric P-Value of this test to its equivalent string representation.
(Inherited from HypothesisTestTDistribution.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The term Z-test is often used to refer specifically to the one-sample location test comparing the mean of a set of measurements to a given constant. Due to the central limit theorem, many test statistics are approximately normally distributed for large samples. Therefore, many statistical tests can be performed as approximate Z-tests if the sample size is large.

If the test is Significant, the null hypothesis can be rejected in favor of the alternate hypothesis specified at the creation of the test.

This test supports creating power analyses through its Analysis property.

References:

Examples

This example has been gathered from the Wikipedia's page about the Z-Test, available from: http://en.wikipedia.org/wiki/Z-test

Suppose there is a text comprehension test being run across a given demographic region. The mean score of the population from this entire region are around 100 points, with a standard deviation of 12 points.

There is a local school, however, whose 55 students attained an average score in the test of only about 96 points. Would their scores be surprisingly that low, or could this event have happened due to chance?

// So we would like to check that a sample of
// 55 students with a mean score of 96 points:

int sampleSize = 55;
double sampleMean = 96;

// Was expected to have happened by chance in a population with
// an hypothesized mean of 100 points and standard deviation of
// about 12 points:

double standardDeviation = 12;
double hypothesizedMean = 100;


// So we start by creating the test:
ZTest test = new ZTest(sampleMean, standardDeviation, sampleSize,
    hypothesizedMean, OneSampleHypothesis.ValueIsSmallerThanHypothesis);

// Now, we can check whether this result would be
// unlikely under a standard significance level:

bool significant  = test.Significant;

// We can also check the test statistic and its P-Value
double statistic = test.Statistic;
double pvalue = test.PValue;
See Also