## Documentation Center |

Sample size and power of test

`n = sampsizepwr(testtype,p0,p1)n = sampsizepwr(testtype,p0,p1,power)power = sampsizepwr(testtype,p0,p1,[],n)p1 = sampsizepwr(testtype,p0,[],power,n)[...] = sampsizepwr(...,n,param1,val1,param2,val2,...)`

`n = sampsizepwr(testtype,p0,p1)` returns
the sample size

The following values are available for * testtype*:

`'z'`—*z*-test for normally distributed data with known standard deviation.`p0`is a two-element vector`[mu0 sigma0]`of the mean and standard deviation, respectively, under the null hypothesis.`p1`is the value of the mean under the alternative hypothesis.`'t'`—*t*-test for normally distributed data with unknown standard deviation.`p0`is a two-element vector`[mu0 sigma0]`of the mean and standard deviation, respectively, under the null hypothesis.`p1`is the value of the mean under the alternative hypothesis.`'var'`— Chi-square test of variance for normally distributed data.`p0`is the variance under the null hypothesis.`p1`is the variance under the alternative hypothesis.`'p'`— Test of the*p*parameter (success probability) for a binomial distribution.`p0`is the value of*p*under the null hypothesis.`p1`is the value of*p*under the alternative hypothesis.The

`'p'`test is a discrete test for which increasing the sample size does not always increase the power. For`n`values larger than 200, there may be values smaller than the returned`n`value that also produce the desired size and power.

`n = sampsizepwr(testtype,p0,p1,power)` returns
the sample size

`power = sampsizepwr(testtype,p0,p1,[],n)` returns
the power achieved for a sample size of

`p1 = sampsizepwr(testtype,p0,[],power,n)` returns
the parameter value detectable with the specified sample size

When computing `p1` for the `'p'` test,
if no alternative can be rejected for a given null hypothesis and
significance level, the function displays a warning message and returns `NaN`.

`[...] = sampsizepwr(...,n,param1,val1,param2,val2,...)` specifies
one or more of the following name/value pairs:

`'alpha'`— Significance level of the test (default 0.05)`'tail'`— The type of test is one of the following:`'both'`— Two-sided test for an alternative not equal to`p0``'right'`— One-sided test for an alternative larger than`p0``'left'`— One-sided test for an alternative smaller than`p0`

Was this topic helpful?