Statistics Toolbox
  Go to function:
    Search    Help Desk 
ztest    Examples

Hypothesis testing for the mean of one sample with known variance.

Syntax

Description

ztest(x,m,sigma) performs a Z test at significance level 0.05 to determine whether a sample from a normal distribution (in x) could have mean m and standard deviation, sigma.

h = ztest(x,m,sigma,alpha) gives control of the significance level, alpha. For example if alpha = 0.01, and the result, h, is 1 you can reject the null hypothesis at the significance level 0.01. If h = 0, you cannot reject the null hypothesis at the alpha level of significance.

[h,sig,ci] = ztest(x,m,sigma,alpha,tail) allows specification of one or two-tailed tests. tail is a flag that specifies one of three alternative hypotheses:

sig is the p-value associated with the Z statistic.

sig is the probability that the observed value of Z could be as large or larger by chance under the null hypothesis that the mean of x is equal to µ.

ci is a 1-alpha confidence interval for the true mean.

Example

This example generates 100 normal random numbers with theoretical mean zero and standard deviation one. The observed mean and standard deviation are different from their theoretical values, of course. We test the hypothesis that there is no true difference.

The result, h = 0, means that we cannot reject the null hypothesis. The significance level is 0.4669, which means that by chance we would have observed values of Z more extreme than the one in this example in 47 of 100 similar experiments. A 95% confidence interval on the mean is [-0.1232 0.2687], which includes the theoretical (and hypothesized) mean of zero.



[ Previous | Help Desk ]