跳转至

pystatpower.mean.single.inequality

FUNCTION DESCRIPTION
solve_power

Calculate the statistical power.

solve_size

Estimate the required sample size.

solve_mean

Estimate the required mean under the alternative hypothesis.

solve_null_mean

Estimate the required mean under the null hypothesis.

solve_diff

Estimate the required mean difference.

solve_std

Estimate the required standard deviation.

solve_power

solve_power(
    *,
    mean: float | None = None,
    null_mean: float | None = None,
    diff: float | None = None,
    std: float,
    size: int,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    dist: Literal["z", "t"] = "t",
) -> float

Calculate the statistical power.

PARAMETER DESCRIPTION
mean

Mean under the alternative hypothesis.

This parameter must be used in conjuction with null_mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

null_mean

Mean under the null hypothesis.

This parameter must be used in conjuction with mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between the alternative hypothesis and the null hypothesis.

If this parameter is specified, both mean and null_mean are ignored.

TYPE: float | None DEFAULT: None

std

Standard deviation.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

RETURNS DESCRIPTION
float

The statistical power of the test.

RAISES DESCRIPTION
ValueError

The given set of parameters is insufficient to determine the mean difference.

solve_size

solve_size(
    *,
    mean: float | None = None,
    null_mean: float | None = None,
    diff: float | None = None,
    std: float,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
) -> int

Estimate the required sample size.

PARAMETER DESCRIPTION
mean

Mean under the alternative hypothesis.

This parameter must be used in conjuction with null_mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

null_mean

Mean under the null hypothesis.

This parameter must be used in conjuction with mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between the alternative hypothesis and the null hypothesis.

If this parameter is specified, both mean and null_mean are ignored.

TYPE: float | None DEFAULT: None

std

Standard deviation.

TYPE: float

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

RETURNS DESCRIPTION
int

The required sample size.

RAISES DESCRIPTION
ValueError

The given set of parameters is insufficient to determine the mean difference.

solve_mean

solve_mean(
    *,
    null_mean: float,
    std: float,
    size: int,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    direction: Literal["greater", "less"] | None = None,
) -> float

Estimate the required mean under the alternative hypothesis.

PARAMETER DESCRIPTION
null_mean

Mean under the null hypothesis.

TYPE: float

std

Standard deviation.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

direction

The search direction for the mean under the alternative hypothesis relative to the mean under the null hypothesis.

  • 'greater': Search for the alternative mean that is greater than the null mean.
  • 'less': Search for the alternative mean that is less than the null mean.

Note

  • If alternative is 'two-sided', the parameter direction is required.
  • If alternative is 'greater', the search direction is automatically inferred to be 'greater', and the parameter direction is ignored.
  • If alternative is 'less', the search direction is automatically inferred to be 'less', and the parameter direction is ignored.

TYPE: Literal['greater', 'less'] | None DEFAULT: None

RETURNS DESCRIPTION
float

The required mean under the alternative hypothesis.

RAISES DESCRIPTION
ValueError

If alternative is 'two-sided' and direction is omitted.

solve_null_mean

solve_null_mean(
    *,
    mean: float,
    std: float,
    size: int,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    direction: Literal["greater", "less"] | None = None,
) -> float

Estimate the required mean under the null hypothesis.

PARAMETER DESCRIPTION
mean

Mean under the alternative hypothesis.

TYPE: float

std

Standard deviation.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

direction

The search direction for the mean under the null hypothesis relative to the mean under the alternative hypothesis.

  • 'greater': Search for the null mean that is greater than the alternative mean.
  • 'less': Search for the null mean that is less than the alternative mean.

Note

  • If alternative is 'two-sided', the parameter direction is required.
  • If alternative is 'greater', the search direction is automatically inferred to be 'less', and the parameter direction is ignored.
  • If alternative is 'less', the search direction is automatically inferred to be 'greater', and the parameter direction is ignored.

TYPE: Literal['greater', 'less'] | None DEFAULT: None

RETURNS DESCRIPTION
float

The required mean under the null hypothesis.

RAISES DESCRIPTION
ValueError

If alternative is 'two-sided' and direction is omitted.

solve_diff

solve_diff(
    *,
    std: float,
    size: int,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    direction: Literal["greater", "less"] | None = None,
) -> float

Estimate the required mean difference.

PARAMETER DESCRIPTION
std

Standard deviation.

TYPE: float

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

direction

The search direction for the mean difference relative to zero.

  • 'greater': Search for the mean difference that is greater than zero.
  • 'less': Search for the mean difference that is less than zero.

Note

  • If alternative is 'two-sided', the parameter direction is required.
  • If alternative is 'greater', the search direction is automatically inferred to be 'greater', and the parameter direction is ignored.
  • If alternative is 'less', the search direction is automatically inferred to be 'less', and the parameter direction is ignored.

TYPE: Literal['greater', 'less'] | None DEFAULT: None

RETURNS DESCRIPTION
float

The required mean difference between the alternative hypothesis and the null hypothesis.

RAISES DESCRIPTION
ValueError

If alternative is 'two-sided' and direction is omitted.

solve_std

solve_std(
    *,
    mean: float | None = None,
    null_mean: float | None = None,
    diff: float | None = None,
    size: int,
    alternative: Literal["two-sided", "greater", "less"] = "two-sided",
    alpha: float = 0.05,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
) -> float

Estimate the required standard deviation.

PARAMETER DESCRIPTION
mean

Mean under the alternative hypothesis.

This parameter must be used in conjuction with null_mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

null_mean

Mean under the null hypothesis.

This parameter must be used in conjuction with mean to compute the diff, where diff = mean - null_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between the alternative hypothesis and the null hypothesis.

If this parameter is specified, both mean and null_mean are ignored.

TYPE: float | None DEFAULT: None

size

Sample size.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is 'two-sided', the alternative hypothesis is \(\mu \neq \mu_0\)
  • If alternative is 'greater', the alternative hypothesis is \(\mu > \mu_0\)
  • If alternative is 'less', the alternative hypothesis is \(\mu < \mu_0\)

TYPE: Literal['two-sided', 'greater', 'less'] DEFAULT: 'two-sided'

alpha

Significance level.

  • If alternative is 'two-sided', alpha represents the two-sided significance level.
  • If alternative is 'greater' or 'less', alpha represents the one-sided significance level.

TYPE: float DEFAULT: 0.05

power

Expected statistical power.

0.8 is a commonly used value for statistical power.

TYPE: float DEFAULT: 0.8

dist

The distribution used for the test.

  • 'z': Normal distribution.
  • 't': Student's t distribution.

TYPE: Literal['z', 't'] DEFAULT: 't'

RETURNS DESCRIPTION
float

The required standard deviation.

RAISES DESCRIPTION
ValueError

The given set of parameters is insufficient to determine the mean difference.