跳转至

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 required sample size for an inequality test of one mean.

solve_null_mean

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

solve_mean

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

solve_power

solve_power(
    *,
    null_mean: float,
    mean: float,
    std: float,
    size: int,
    alternative: Literal[
        "two-sided", "lower one-sided", "upper one-sided"
    ],
    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['two-sided', 'lower one-sided', 'upper one-sided']

Type of the alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\mu_1 \neq \mu_0\)
  • 'lower one-sided': Lower one-sided alternative hypothesis: \(\mu_1 < \mu_0\)
  • 'upper one-sided': Upper one-sided alternative hypothesis: \(\mu_1 > \mu_0\)
required
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'lower one-sided' or 'upper one-sided', provide the one-sided 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[
        "two-sided", "lower one-sided", "upper one-sided"
    ],
    alpha: float,
    power: float,
    method: Literal["z", "t"],
) -> int

Estimate the required sample size 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['two-sided', 'lower one-sided', 'upper one-sided']

Type of the alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\mu_1 \neq \mu_0\)
  • 'lower one-sided': Lower one-sided alternative hypothesis: \(\mu_1 < \mu_0\)
  • 'upper one-sided': Upper one-sided alternative hypothesis: \(\mu_1 > \mu_0\)
required
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'lower one-sided' or 'upper one-sided', provide the one-sided 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:

Type Description
int

The required sample size.

solve_null_mean

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

Estimate the required mean under the null hypothesis 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['two-sided', 'lower one-sided', 'upper one-sided']

Type of the alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\mu_1 \neq \mu_0\)
  • 'lower one-sided': Lower one-sided alternative hypothesis: \(\mu_1 < \mu_0\)
  • 'upper one-sided': Upper one-sided alternative hypothesis: \(\mu_1 > \mu_0\)
required
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'lower one-sided' or 'upper one-sided', provide the one-sided 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:

Type Description
float

The required mean under the null hypothesis.

solve_mean

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

Estimate the required mean under the alternative hypothesis 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['two-sided', 'lower one-sided', 'upper one-sided']

Type of the alternative hypothesis.

  • 'two-sided': Two-sided alternative hypothesis: \(\mu_1 \neq \mu_0\)
  • 'lower one-sided': Lower one-sided alternative hypothesis: \(\mu_1 < \mu_0\)
  • 'upper one-sided': Upper one-sided alternative hypothesis: \(\mu_1 > \mu_0\)
required
alpha float

Significance level.

  • If alternative is 'two-sided', provide the two-sided significance level.
  • If alternative is 'lower one-sided' or 'upper one-sided', provide the one-sided 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:

Type Description
float

The required mean under the alternative hypothesis.