in spotify_confidence/samplesize/sample_size_calculator.py [0:0]
def _get_alpha(alpha, power, bonferroni, treatments, comparisons):
"""Validate and potentially correct false positive rate.
Args:
alpha (float): Probability of Type I error (false positive).
bonferroni (bool): Whether Bonferroni correction should be applied
to control the false positive rate across all comparisons.
treatments (int): Number of treatment variants in the a/b test,
including control.
comparisons ({'control_vs_all', 'all_vs_all'}, optional): Which
treatments to compare.
Returns:
float: False positive rate, potentially Bonferroni corrected.
Raises:
ValueError: If `power` is less than or equal to `alpha`.
TypeError: If `bonferroni` is not a bool.
"""
power = SampleSize._validate_percentage(power)
alpha = SampleSize._validate_percentage(alpha)
if power <= alpha:
raise ValueError("alpha must be less than power")
elif not isinstance(bonferroni, bool):
raise TypeError("bonferroni must be a bool")
num_comparisons = SampleSize._num_comparisons(treatments, comparisons)
if bonferroni:
return alpha / num_comparisons
else:
return alpha