### Function Reference: `ztest`

statistics: h = ztest (x, m, sigma)
statistics: h = ztest (x, m, sigma, Name, Value)
statistics: [h, pval] = ztest (…)
statistics: [h, pval, ci] = ztest (…)
statistics: [h, pval, ci, zvalue] = ztest (…)

One-sample Z-test.

`h = ztest (x, v)` performs a Z-test of the hypothesis that the data in the vector x come from a normal distribution with mean m, against the alternative that x comes from a normal distribution with a different mean m. The result is h = 0 if the null hypothesis ("mean is M") cannot be rejected at the 5% significance level, or h = 1 if the null hypothesis can be rejected at the 5% level.

x may also be a matrix or an N-D array. For matrices, `ztest` performs separate tests along each column of x, and returns a vector of results. For N-D arrays, `ztest` works along the first non-singleton dimension of x. m and sigma must be a scalars.

`ztest` treats NaNs as missing values, and ignores them.

`[h, pval] = ztest (…)` returns the p-value. That is the probability of observing the given result, or one more extreme, by chance if the null hypothesisis true.

`[h, pval, ci] = ztest (…)` returns a 100 * (1 - alpha)% confidence interval for the true mean.

`[h, pval, ci, zvalue] = ztest (…)` returns the value of the test statistic.

`[…] = ztest (…, Name, Value, …)` specifies one or more of the following Name/Value pairs:

| Name | Value
--- | --- | ---
| "alpha" | the significance level. Default is 0.05.
| "dim" | dimension to work along a matrix or an N-D array.
| "tail" | a string specifying the alternative hypothesis:

| "both" | "mean is not m" (two-tailed, default)
| "left" | "mean is less than m" (left-tailed)
| "right" | "mean is greater than m" (right-tailed)

See also: ttest, vartest, signtest, kstest

Source Code: ztest