Dew Stats Master .NET
ZTest Routine
Summary
Z Test.

Unit
Statistics

Declaration
Function ZTest(Data: TVec; Mean, Sigma: TSample; out hRes: THypothesisResult; out Signif: TSample; out ConfInt: TTwoElmReal; hType: THypothesisType = htTwoTailed; Alpha: TSample = 0.05): TSample;
 Parameter  Description 
hRes Returns the result of the null hypothesis (default assumption is that the means are equal). 
hType Defines the type of the null hypothesis (left, right and two - tailed). 
Signif (Significance level) returns the probability of observing the given result by chance given that the null hypothesis is true. 
ConfInt Returns the 100*(1-Alpha) percent confidence interval for the mean. 
Alpha Defines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected. 
Result
Z statistic.
Description
Compares the normally distributed Data elements mean value with known standard deviation Sigma, to a mean value Mean.
Categories
Hypothesis testing
 See Also 
TTest 

Example 1

In this example we'll use Z-Test to determine if data mean and variance are equal to specific values.

Uses MtxExpr, Math387, Statistics; procedure Example; var d: Vector; Signif : TSample; HypRes : THypothesisResult; MeanCI : TTwoElmReal; begin d.SetIt(false,[3,3.5,2,3.1,10,9]); ZTest(d, 5, 1.29, HypRes, Signif, MeanCI); // Signif = 0.84940087229; HypRes = hrNotReject; // MeanCI=[4.06780398958, 6.13219601041] // Comment : Since the SignRes is greater than Alpha (0.05), the // null hypothesis (H0) that data mean is equal to 5.1 cannot be rejected // the alternative (Ha) that data mean are NOT equal can therefore be // rejected end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "Statistics.hpp" void __fastcall Example(); { Vector data; data->SetIt(false, OPENARRAY(TSample, (3,3.5,2,3.1,10,9))); double signif, ZStat; double ci[2]; THypothesisResult hres; // don't use normal approximation ZStat = ZTest(data, 5.0, 1.29, hres,signif,ci,htTwoTailed,0.05); // signif = 0.84940087229; hres = hrNotReject; // ci=[4.06780398958, 6.13219601041] // Comment : Since the SignRes is greater than Alpha (0.05), the // null hypothesis (H0) that data mean is equal to 5.1 cannot be rejected // the alternative (Ha) that data mean are NOT equal can therefore be // rejected }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector data = new Vector(0); d1.SetIt(false, new double[] {3,3.5,2,3.1,10,9}); double signif, ZStat; double[2] ci; THypothesisResult hres; // don't use normal approximation ZStat = Statistics.ZTest(data, 5.0, 1.29,out hres,out signif,out ci,THypothesisType.htTwoTailed,0.05); // signif = 0.84940087229; hres = hrNotReject; // ci=[4.06780398958, 6.13219601041] // Comment : Since the SignRes is greater than Alpha (0.05), the // null hypothesis (H0) that data mean is equal to 5.1 cannot be rejected // the alternative (Ha) that data mean are NOT equal can therefore be // rejected } }


Copyright 2008 Dew Research
http://www.dewresearch.com