跳转至

pystatpower.mean.independent.ci

Functions:

Name Description
solve_precision

Calculate the distance from the mean difference to the confidence limit.

solve_size

Estimate the required sample size, given the distance from the mean difference to the confidence limit.

solve_precision

solve_precision(
    *,
    treatment_std: float,
    reference_std: float,
    treatment_size: int,
    reference_size: int,
    conf_level: float = 0.95,
    interval_type: Literal[
        "two-sided", "lower", "upper"
    ] = "two-sided",
    equal_var: bool = False,
) -> float

Calculate the distance from the mean difference to the confidence limit.

Parameters:

Name Type Description Default
treatment_std float

Standard deviation in the treatment group.

required
reference_std float

Standard deviation in the reference group.

required
treatment_size int

Sample size in the treatment group.

required
reference_size int

Sample size in the reference group.

required
conf_level float

Confidence level.

0.95
interval_type Literal['two-sided', 'lower', 'upper']

The type of confidence interval.

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

Specify whether the variances are assumed to be equal.

  • True: The variances are assumed to be equal. In this case, the standard t-test is used.
  • False: The variances are not assumed to be equal. In this case, Welch-Satterthwaite's approximate t-test is used.
False

Returns:

Name Type Description
float float

The distance from the mean difference to the confidence limit.

solve_size

solve_size(
    *,
    treatment_std: float,
    reference_std: float,
    precision: float,
    ratio: float = 1,
    conf_level: float = 0.95,
    interval_type: Literal[
        "two-sided", "lower", "upper"
    ] = "two-sided",
    equal_var: bool = False,
) -> tuple[int, int]

Estimate the required sample size, given the distance from the mean difference to the confidence limit.

Parameters:

Name Type Description Default
treatment_std float

Standard deviation in the treatment group.

required
reference_std float

Standard deviation in the reference group.

required
precision float

The distance from the mean difference to the confidence limit.

required
ratio float

The ratio of the sample size in the treatment group to the sample size in the reference group.

1
conf_level float

Confidence level.

0.95
interval_type Literal['two-sided', 'lower', 'upper']

The type of confidence interval.

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

Specify whether the variances are assumed to be equal.

  • True: The variances are assumed to be equal. In this case, the standard t-test is used.
  • False: The variances are not assumed to be equal. In this case, Welch-Satterthwaite's approximate t-test is used.
False

Returns:

Type Description
tuple[int, int]

tuple[int, int]: The required sample size in the treatment and reference groups, respectively.