You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.ZTest Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Statistics.ZTest Function

Z Test.

Pascal
function ZTest(const Data: TVec; const Mean: double; const Sigma: double; out hRes: THypothesisResult; out Signif: double; var ConfInt: TTwoElmReal; const hType: THypothesisType = htTwoTailed; const Alpha: double = 0.05): double;
Parameters 
Description 
Data 
The data samples to be analyzed. 
Mean 
The mean to value to compare the data to. 
Sigma 
The standard deviation to compare the data to. 
hRes 
Returns the result of the null hypothesis (default assumption is that the means are equal). 
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. 
hType 
Defines the type of the null hypothesis (left, right and two - tailed). 
Alpha 
Defines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected. 

Z statistics.

Compares the normally distributed Data elements mean value with known standard deviation Sigma, to a mean value Mean.

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  : double;
  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 "MtxExpr.hpp"
#include "Math387.hpp"
#include "Statistics.hpp"
void __fastcall Example()
{
  sVector data;
  data.SetIt(false, OPENARRAY(double, (3,3.5,2,3.1,10,9)));
  double signif, ZStat;
  TTwoElmReal ci;
  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
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!