ztest2
Two proportions Z-test.
If x1 and n1 are the counts of successes and trials in one sample, and x2 and n2 those in a second one, test the null hypothesis that the success probabilities and are the same. The result is h = 0 if the null hypothesis cannot be rejected at the 5% significance level, or h = 1 if the null hypothesis can be rejected at the 5% level.
Under the null, the test statistic zvalue approximately follows a standard normal distribution.
The size of h, pval, and zvalue is the common size of x, n1, x2, and n2, which must be scalars or of common size. A scalar input functions as a constant matrix of the same size as the other inputs.
[h, pval] = ztest2 (…)
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, zvalue] = ztest2 (…)
returns the
value of the test statistic.
[…] = ztest2 (…, Name, Value, …)
specifies one or more of the following Name/Value pairs:
Name | Value | |
---|---|---|
"alpha" | the significance level. Default is 0.05. | |
"tail" | a string specifying the alternative hypothesis |
"both" | is not (two-tailed, default) | |
"left" | is less than (left-tailed) | |
"right" | is greater than (right-tailed) |
See also: chi2test, fishertest
Source Code: ztest2