跳转至

pystatpower.mean.independent.superiority

FUNCTION DESCRIPTION
solve_power

Calculate the statistical power.

solve_size

Estimate the required sample size.

solve_diff

Estimate the required mean difference.

solve_treatment_mean

Estimate the required mean in the treatment group.

solve_reference_mean

Estimate the required mean in the reference group.

solve_margin

Estimate the required superiority margin.

solve_treatment_std

Estimate the required standard deviation in the treatment group.

solve_reference_std

Estimate the required standard deviation in the reference group.

solve_power

solve_power(
    *,
    treatment_mean: float | None = None,
    reference_mean: float | None = None,
    diff: float | None = None,
    margin: float,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Calculate the statistical power.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

If diff is omitted, this parameter is required along with reference_mean.

TYPE: float | None DEFAULT: None

reference_mean

Mean in the reference group.

If diff is omitted, this parameter is required along with treatment_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between treatment and reference group.

If both treatment_mean and reference_mean are not specified, this parameter is required.

TYPE: float | None DEFAULT: None

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

dist

The distribution used for the test.

  • 'z': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The statistical power of the test.

RAISES DESCRIPTION
ValueError

If all of diff, treatment_mean and reference_mean are omitted.

ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_size

solve_size(
    *,
    treatment_mean: float | None = None,
    reference_mean: float | None = None,
    diff: float | None = None,
    margin: float,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    ratio: float = 1,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> tuple[int, int]

Estimate the required sample size.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

If diff is omitted, this parameter is required along with reference_mean.

TYPE: float | None DEFAULT: None

reference_mean

Mean in the reference group.

If diff is omitted, this parameter is required along with treatment_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between treatment and reference group.

If both treatment_mean and reference_mean are not specified, this parameter is required.

TYPE: float | None DEFAULT: None

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

ratio

Ratio of sample sizes in the treatment and reference groups.

TYPE: float DEFAULT: 1

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
tuple[int, int]

The required sample sizes in the treatment and reference groups, respectively.

RAISES DESCRIPTION
ValueError

If all of diff, treatment_mean and reference_mean are omitted.

ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_diff

solve_diff(
    *,
    margin: float,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required mean difference.

PARAMETER DESCRIPTION
margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required difference between the mean in treatment and reference groups.

RAISES DESCRIPTION
ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_treatment_mean

solve_treatment_mean(
    *,
    reference_mean: float,
    margin: float,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required mean in the treatment group.

PARAMETER DESCRIPTION
reference_mean

Mean in the reference group.

TYPE: float

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required mean in the treatment group.

RAISES DESCRIPTION
ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_reference_mean

solve_reference_mean(
    *,
    treatment_mean: float,
    margin: float,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required mean in the reference group.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

TYPE: float

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required mean in the reference group.

RAISES DESCRIPTION
ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_margin

solve_margin(
    *,
    treatment_mean: float | None = None,
    reference_mean: float | None = None,
    diff: float | None = None,
    treatment_std: float | None = None,
    reference_std: float | None = None,
    std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = False,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required superiority margin.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

If diff is omitted, this parameter is required along with reference_mean.

TYPE: float | None DEFAULT: None

reference_mean

Mean in the reference group.

If diff is omitted, this parameter is requiredside treatment_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between treatment and reference group.

If both treatment_mean and reference_mean are not specified, this parameter is required.

TYPE: float | None DEFAULT: None

treatment_std

Standard deviation in the treatment group.

TYPE: float | None DEFAULT: None

reference_std

Standard deviation in the reference group.

TYPE: float | None DEFAULT: None

std

Standard deviation in both groups.

This is a convenience parameter that will override treatment_std and reference_std when dist is z and equal_var is True.

If you specify dist as z and equal_var as True, you can just specify std instead of treatment_std and reference_std. Internally, the value of std will be treated as the standard deviation of both the treatment and reference groups.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: False

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required superiority margin for the test.

  • If alternative is greater, the returned value is in the range \([0, \hat{\mu}_1 - \hat{\mu}_2)\)
  • If alternative is less, the returned value is in the range \((\hat{\mu}_1 - \hat{\mu}_2, 0]\)
RAISES DESCRIPTION
ValueError

If all of diff, treatment_mean and reference_mean are omitted.

ValueError

If dist is z and equal_var is True, and all treatment_std, reference_std and std is omitted.

ValueError

If dist is z and equal_var is True, and both treatment_std and reference_std are provided, but they are not equal.

solve_treatment_std

solve_treatment_std(
    *,
    treatment_mean: float | None = None,
    reference_mean: float | None = None,
    diff: float | None = None,
    margin: float,
    reference_std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = True,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required standard deviation in the treatment group.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

If diff is omitted, this parameter is required along with reference_mean.

TYPE: float | None DEFAULT: None

reference_mean

Mean in the reference group.

If diff is omitted, this parameter is required along with treatment_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between treatment and reference group.

If both treatment_mean and reference_mean are not specified, this parameter is required.

TYPE: float | None DEFAULT: None

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

reference_std

Standard deviation in the reference group.

  • If dist is z and equal_var is True, this parameter is ignored.
  • If dist is z and equal_var is False, this parameter is required.
  • If dist is t and equal_var is True, this parameter is optional. If specified, this value is used to calculate the standard error of mean difference.
  • If dist is t and equal_var is False, this parameter is required.

TYPE: float | None DEFAULT: None

treatment_size

Sample size in the treatment group.

TYPE: int

reference_size

Sample size in the reference group.

TYPE: int

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: True

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required standard deviation in the treatment group.

RAISES DESCRIPTION
ValueError

If all of diff, treatment_mean and reference_mean are omitted.

ValueError

If equal_var is False, and reference_std is omitted.

solve_reference_std

solve_reference_std(
    *,
    treatment_mean: float | None = None,
    reference_mean: float | None = None,
    diff: float | None = None,
    margin: float,
    treatment_std: float | None = None,
    treatment_size: int,
    reference_size: int,
    alternative: Literal["greater", "less"],
    alpha: float = 0.025,
    power: float = 0.8,
    dist: Literal["z", "t"] = "t",
    equal_var: bool = True,
    approx_t_method: Literal["welch", "satterthwaite"] = "welch",
) -> float

Estimate the required standard deviation in the reference group.

PARAMETER DESCRIPTION
treatment_mean

Mean in the treatment group.

If diff is omitted, this parameter is required along with reference_mean.

TYPE: float | None DEFAULT: None

reference_mean

Mean in the reference group.

If diff is omitted, this parameter is required along with treatment_mean.

TYPE: float | None DEFAULT: None

diff

Mean difference between treatment and reference group.

If both treatment_mean and reference_mean are not specified, this parameter is required.

TYPE: float | None DEFAULT: None

margin

The superiority margin.

Tip

Regardless of whether alternative is specified as 'greater' or 'less', you can always specify this parameter as either positive or negative, as you prefer. Internally, the value of margin is converted before actual calculation takes place.

  • If alternative is greater, the actual margin used internally is abs(margin).
  • If alternative is less, the actual margin used internally is -abs(margin).

TYPE: float

treatment_std

Standard deviation in the treatment group.

  • If dist is z and equal_var is True, this parameter is ignored.
  • If dist is z and equal_var is False, this parameter is required.
  • If dist is t and equal_var is True, this parameter is optional. If specified, this value is used to calculate the standard error of mean difference.
  • If dist is t and equal_var is False, this parameter is required.

TYPE: float | None DEFAULT: None

alternative

Type of the alternative hypothesis.

  • If alternative is greater, the alternative hypothesis is \(\mu_1 - \mu_2 > \delta\) (\(\delta \geqslant 0\))
  • If alternative is less, the alternative hypothesis is \(\mu_1 - \mu_2 < \delta\) (\(\delta \leqslant 0\))

TYPE: Literal['greater', 'less']

alpha

Significance level.

The superiority test is a one-sided test, with a significance level of 0.025 being commonly used.

TYPE: float DEFAULT: 0.025

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': Standard normal distribution.
  • 't': Student's or non-central t distribution.

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

equal_var

Whether to assume equal variances between treatment and reference groups.

  • True: Variances are assumed equal.
  • False: Variances are assumed unequal.

TYPE: bool DEFAULT: True

approx_t_method

Approximate t-test method. It is used when dist is 't' and equal_var = False.

  • 'welch': Welch's approximate t-test (1947).
  • 'satterthwaite': Satterthwaite's approximate t-test (1946).

TYPE: Literal['welch', 'satterthwaite'] DEFAULT: 'welch'

RETURNS DESCRIPTION
float

The required standard deviation in the reference group.

RAISES DESCRIPTION
ValueError

If all of diff, treatment_mean and reference_mean are omitted.

ValueError

If equal_var is False, and treatment_std is omitted.