跳转至

pystatpower.models.mean.single.ci

Functions:

Name Description
solve_half_width

Calculate the half-width of the confidence interval for one mean.

solve_size

Calculate the required sample size for the half-width of one mean confidence interval.

solve_std

Calculate the required standard deviation for the half-width of one mean confidence interval.

solve_half_width

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

Calculate the half-width of the confidence interval for one mean.

Parameters:

Name Type Description Default
std float

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

required
size int

Sample size (\(n\)).

required
conf_level (float, Optional)

Confidence level.

0.95
interval_type Literal['one-sided', 'two-sided']

The type of confidence interval.

'two-sided'
method Literal['z', 't']

The distribution used to construct the confidence interval.

't'

Returns:

Type Description
float

The half-width of the confidence interval for one mean.

solve_size

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

Calculate the required sample size for the half-width of one mean confidence interval.

Parameters:

Name Type Description Default
half_width float

Half-width of the confidence interval (\(d\)).

required
std float

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

required
conf_level (float, Optional)

Confidence level.

0.95
interval_type Literal['one-sided', 'two-sided']

The type of confidence interval.

'two-sided'
method Literal['z', 't']

The distribution used to construct the confidence interval.

't'

Returns:

Type Description
int

The required sample size.

solve_std

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

Calculate the required standard deviation for the half-width of one mean confidence interval.

Parameters:

Name Type Description Default
half_width float

Half-width of the confidence interval (\(d\)).

required
size int

Sample size (\(n\)).

required
conf_level (float, Optional)

Confidence level.

0.95
interval_type Literal['one-sided', 'two-sided']

The type of confidence interval.

'two-sided'
method Literal['z', 't']

The distribution used to construct the confidence interval.

't'

Returns:

Type Description
float

The required standard deviation.