Skip to content

Commit

Permalink
required sample size is zero (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
jancervenka authored Mar 7, 2024
1 parent 7362213 commit 553f2f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ep-stats
version = 2.3.0
version = 2.3.1
description = Statistical package to evaluate ab tests in experimentation platform.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down
2 changes: 2 additions & 0 deletions src/epstats/toolkit/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ def __str__(self):
return f"{self.value}"

def evaluate_agg(self, goals):
# n_variants = goals["exp_variant_id"].nunique()
# return [self.value] * n_variants
return self.value

def evaluate_by_unit(self, goals):
Expand Down
2 changes: 1 addition & 1 deletion src/epstats/toolkit/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def power_from_required_sample_size_per_variant(
power
"""

if n_variants < 2:
if n_variants < 2 or required_sample_size_per_variant == 0:
return np.nan

required_sample_size_ratio = sample_size_per_variant / required_sample_size_per_variant
Expand Down
20 changes: 20 additions & 0 deletions tests/epstats/toolkit/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,23 @@ def test_power_from_required_sample_size_per_variant_nan_params():
required_sample_size_per_variant=np.nan,
)
)


@pytest.mark.parametrize(
"args",
[
{
"n_variants": 1,
"sample_size_per_variant": 100,
"required_sample_size_per_variant": 100,
},
{
"n_variants": 2,
"sample_size_per_variant": 0,
"required_sample_size_per_variant": 0,
},
],
)
def test_power_from_required_sample_size_per_variant_is_nan(args):

assert np.isnan(Statistics.power_from_required_sample_size_per_variant(**args))

0 comments on commit 553f2f1

Please sign in to comment.