跳转至

pystatpower.mean.single.ci

FUNCTION DESCRIPTION
solve_precision

Calculate the distance from the mean to the confidence limit (commonly known as precision).

solve_size

Estimate the required sample size.

solve_std

Estimate the required standard deviation.

solve_precision

solve_precision(
    *,
    std: float,
    size: int,
    conf_level: float = 0.95,
    interval_type: Literal["two-sided", "one-sided", "lower", "upper"] = "two-sided",
    dist: Literal["z", "t"] = "t",
) -> float

Calculate the distance from the mean to the confidence limit (commonly known as precision).

PARAMETER DESCRIPTION
std

Standard deviation.

TYPE: float

size

Sample size.

TYPE: int

conf_level

Confidence level.

  • If interval_type is 'two-sided', a two-sided confidence level should be specified
  • If interval_type is 'one-sided', 'lower' or 'upper', a one-sided confidence level should be specified

TYPE: float DEFAULT: 0.95

interval_type

The type of confidence interval.

  • 'two-sided': Two-sided confidence interval.
  • 'one-sided': One-sided confidence interval.
  • 'lower': Lower one-sided confidence interval.
  • 'upper': Upper one-sided confidence interval.

TYPE: Literal['two-sided', 'one-sided', 'lower', 'upper'] DEFAULT: 'two-sided'

dist

The distribution used to construct the confidence interval.

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

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

RETURNS DESCRIPTION
float

The distance from the mean to the confidence limit (commonly known as precision).

Notes

Since the confidence interval for the mean is symmetric, specifying interval_type as 'lower', 'upper', or 'one-sided' works consistently.

solve_size

solve_size(
    *,
    precision: float,
    std: float,
    conf_level: float = 0.95,
    interval_type: Literal["two-sided", "one-sided", "lower", "upper"] = "two-sided",
    dist: Literal["z", "t"] = "t",
) -> int

Estimate the required sample size.

PARAMETER DESCRIPTION
precision

Distance from the mean to the confidence limit.

TYPE: float

std

Standard deviation.

TYPE: float

conf_level

Confidence level.

  • If interval_type is 'two-sided', a two-sided confidence level should be specified
  • If interval_type is 'one-sided', 'lower' or 'upper', a one-sided confidence level should be specified

TYPE: float DEFAULT: 0.95

interval_type

The type of confidence interval.

  • 'two-sided': Two-sided confidence interval.
  • 'one-sided': One-sided confidence interval.
  • 'lower': Lower one-sided confidence interval.
  • 'upper': Upper one-sided confidence interval.

TYPE: Literal['two-sided', 'one-sided', 'lower', 'upper'] DEFAULT: 'two-sided'

dist

The distribution used to construct the confidence interval.

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

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

RETURNS DESCRIPTION
int

The required sample size.

Notes

Since the confidence interval for the mean is symmetric, specifying interval_type as 'lower', 'upper', or 'one-sided' works consistently.

solve_std

solve_std(
    *,
    precision: float,
    size: int,
    conf_level: float = 0.95,
    interval_type: Literal["two-sided", "one-sided", "lower", "upper"] = "two-sided",
    dist: Literal["z", "t"] = "t",
) -> float

Estimate the required standard deviation.

PARAMETER DESCRIPTION
precision

Distance from the mean to the confidence limit.

TYPE: float

size

Sample size.

TYPE: int

conf_level

Confidence level.

  • If interval_type is 'two-sided', a two-sided confidence level should be specified
  • If interval_type is 'one-sided', 'lower' or 'upper', a one-sided confidence level should be specified

TYPE: float DEFAULT: 0.95

interval_type

The type of confidence interval.

  • 'two-sided': Two-sided confidence interval.
  • 'one-sided': One-sided confidence interval.
  • 'lower': Lower one-sided confidence interval.
  • 'upper': Upper one-sided confidence interval.

TYPE: Literal['two-sided', 'one-sided', 'lower', 'upper'] DEFAULT: 'two-sided'

dist

The distribution used to construct the confidence interval.

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

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

RETURNS DESCRIPTION
float

The required standard deviation.

Notes

Since the confidence interval for the mean is symmetric, specifying interval_type as 'lower', 'upper', or 'one-sided' works consistently.