跳转至

pystatpower.models.mean.single.inequality

Functions:

Name Description
solve_power

Calculate the statistical power for an inequality test of one mean.

solve_size

Estimate the sample size required for an inequality test of one mean.

solve_null_mean

Estimate the mean under the null hypothesis required for an inequality test of one mean.

solve_mean

Estimate the mean under the alternative hypothesis required for an inequality test of one mean.

solve_power

solve_power(*, null_mean: float, mean: float, std: float, size: int, alternative: Literal['lower', 'upper', 'both'], alpha: float, method: Literal['z', 't']) -> float

Calculate the statistical power for an inequality test of one mean.

Parameters:

Name Type Description Default
null_mean float

Mean under the null hypothesis (\(\mu_0\)).

required
mean float

Mean under the alternative hypothesis (\(\mu_1\)).

required
std float

Standard deviation (\(\sigma\)). If method='t', provide the sample standard deviation (\(S\)).

required
size int

Sample size (\(n\)).

required
alternative Literal['lower', 'upper', 'both']

The direction of the alternative hypothesis.

  • 'lower': lower-tailed alternative hypothesis: \(H_1: \mu_1 < \mu_0\)
  • 'upper': upper-tailed alternative hypothesis: \(H_1: \mu_1 > \mu_0\)
  • 'both': two-tailed alternative hypothesis: \(H_1: \mu_1 \neq \mu_0\)
required
alpha float

Significance level.

required
method Literal['z', 't']

The distribution used for the test.

  • 'z': Standard normal distribution (large sample approximation).
  • 't': Student's t distribution.
required

Returns:

Type Description
float

The calculated statistical power of the test.

solve_size

solve_size(*, null_mean: float, mean: float, std: float, alternative: Literal['lower', 'upper', 'both'], alpha: float, power: float, method: Literal['z', 't']) -> int

Estimate the sample size required for an inequality test of one mean.

Parameters:

Name Type Description Default
null_mean float

Mean under the null hypothesis (\(\mu_0\)).

required
mean float

Mean under the alternative hypothesis (\(\mu_1\)).

required
std float

Standard deviation (\(\sigma\)). If method='t', provide the sample standard deviation (\(S\)).

required
alternative Literal['lower', 'upper', 'both']

The direction of the alternative hypothesis.

  • 'lower': lower-tailed alternative hypothesis: \(H_1: \mu_1 < \mu_0\)
  • 'upper': upper-tailed alternative hypothesis: \(H_1: \mu_1 > \mu_0\)
  • 'both': two-tailed alternative hypothesis: \(H_1: \mu_1 \neq \mu_0\)
required
alpha float

Significance level.

required
power float

Desired statistical power.

required
method Literal['z', 't']

The distribution used for the test.

  • 'z': Standard normal distribution (large sample approximation).
  • 't': Student's t distribution.
required

Returns:

Name Type Description
int int

The required sample size.

solve_null_mean

solve_null_mean(*, mean: float, std: float, size: int, alternative: Literal['lower', 'upper', 'both'], alpha: float, power: float, method: Literal['z', 't'], search_direction: Literal['below', 'above'] = 'below') -> float

Estimate the mean under the null hypothesis required for an inequality test of one mean.

Parameters:

Name Type Description Default
mean float

Mean under the alternative hypothesis (\(\mu_1\)).

required
std float

Standard deviation (\(\sigma\)). If method='t', provide the sample standard deviation (\(S\)).

required
size int

Sample size (\(n\)).

required
alternative Literal['lower', 'upper', 'both']

The direction of the alternative hypothesis.

  • 'lower': lower-tailed alternative hypothesis: \(H_1: \mu_1 < \mu_0\)
  • 'upper': upper-tailed alternative hypothesis: \(H_1: \mu_1 > \mu_0\)
  • 'both': two-tailed alternative hypothesis: \(H_1: \mu_1 \neq \mu_0\)
required
alpha float

Significance level.

required
power float

Desired statistical power.

required
method Literal['z', 't']

The distribution used for the test.

  • 'z': Standard normal distribution (large sample approximation).
  • 't': Student's t distribution.
required
search_direction Literal['below', 'above']

Specify whether to search for the null mean below or above the alternative mean.

  • 'below': Search the null mean below the alternative mean.
  • 'above': Search the null mean above the alternative mean.
'below'

Returns:

Name Type Description
float float

The required mean under the null hypothesis.

solve_mean

solve_mean(*, null_mean: float, std: float, size: int, alternative: Literal['lower', 'upper', 'both'], alpha: float, power: float, method: Literal['z', 't'], search_direction: Literal['below', 'above'] = 'above') -> float

Estimate the mean under the alternative hypothesis required for an inequality test of one mean.

Parameters:

Name Type Description Default
null_mean float

Mean under the null hypothesis (\(\mu_0\)).

required
std float

Standard deviation (\(\sigma\)). If method='t', provide the sample standard deviation (\(S\)).

required
size int

Sample size (\(n\)).

required
alternative Literal['lower', 'upper', 'both']

The direction of the alternative hypothesis.

  • 'lower': lower-tailed alternative hypothesis: \(H_1: \mu_1 < \mu_0\)
  • 'upper': upper-tailed alternative hypothesis: \(H_1: \mu_1 > \mu_0\)
  • 'both': two-tailed alternative hypothesis: \(H_1: \mu_1 \neq \mu_0\)
required
alpha float

Significance level.

required
power float

Desired statistical power.

required
method Literal['z', 't']

The distribution used for the test.

  • 'z': Standard normal distribution (large sample approximation).
  • 't': Student's t distribution.
required
search_direction Literal['below', 'above']

Specify whether to search for the alternative mean below or above the null mean.

  • 'below': Search the alternative mean below the null mean.
  • 'above': Search the alternative mean above the null mean.
'above'

Returns:

Name Type Description
float float

The required mean under the alternative hypothesis.