ztest
Hypothesis test for the mean of a sample with known standard deviation.
Syntax
[h,pvalue,ci] = ztest(x,m,sigma)
[h,pvalue,ci] = ztest(x,m,sigma,name,value)
Inputs
- x
- Data sample to be tested.
- m
- Hypothesis mean.
- sigma
- Populations standard deviation.
- name
- Name of an option whose value follows. Multiple name/value pairs are allowed. The supported options are alpha and dim.
- value
- Value for the preceeding option name.
Outputs
- h
- 0 if the null hypothesis is accepted. 1 if the null hypothesis is rejected.
- pvalue
- The p-value of the test.
- ci
- A 100*(1-alpha)% confidence interval for the population mean.
Example
Vector ztest example
x = [7.3 9.4 5.9 6.5 5.5 7 5.3 7.3 2.6 8.7 8.1 2.5 3.9 1.4 0.2 4 6 6.1 10.3 1.2];
[h,pvalue,ci] = ztest(x,5,2)
h = 0
pvalue = 0.30367
ci = [Matrix] 1 x 2
4.5835 6.3365
Comments
ztest is a 1 sample z test and assumes that the sample comes from a normally distributed population. The null hypothesis is that the hypothesized mean is the population mean.