Skip to content

Commit

Permalink
alpha correction fix (#23) (#26)
Browse files Browse the repository at this point in the history
* alpha correction fix

* version fix

* version fix
  • Loading branch information
jancervenka committed Jan 18, 2022
1 parent 82f48bf commit 690bbda
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 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 = 1.0.0
version = 1.0.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: 1 addition & 1 deletion src/epstats/toolkit/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ def obf_alpha_spending_function(cls, confidence_level: int, total_length: int, a
t = actual_day / total_length # t in (0, 1]
q = st.norm.ppf(1 - alpha / 2) # quantile of normal distribution
alpha_adj = 2 - 2 * st.norm.cdf(q / np.sqrt(t))
return 1 - alpha_adj
return np.round(1 - alpha_adj, decimals=4)
4 changes: 2 additions & 2 deletions src/epstats/toolkit/testing/resources/evaluations_metrics.csv
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ test-srm-negative b 1 Click-through Rate 5100 1100 1100 0.2156862745 0.015686274
test-srm-negative c 1 Click-through Rate 5300 900 900 0.1698113208 -0.0301886792 -0.1509433962 0.3755023838 0.0000586106 0.0352411269 -4.2831603193 10148.5415473186 0.0000185954 0.0000371908 0.5000005708 0.9749999715 N/A 0.0790012661 0.95
test-srm-one-variant a 1 Click-through Rate 0 0 0 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A #N/A 0.9500000000 N/A N/A 0.95
test-srm-one-variant b 1 Click-through Rate 5100 1100 1100 0.2156862745 -inf N/A 0.4113379167 N/A N/A N/A N/A N/A N/A #N/A 0.9500000000 N/A N/A 0.95
test-sequential-v1 a 1 Average Bookings 2000 44400 2308800 22.2000000000 0.0000000000 0.0000000000 25.7272413110 0.6618909455 0.0366471534 0.0000000000 3998.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000 N/A 0.2696570065 1.00
test-sequential-v1 b 1 Average Bookings 2020 35000 1700000 17.3267326733 -4.8732673267 -0.2195165462 23.2730881112 0.5990824184 0.0308725819 -7.1104045326 3970.1185027169 0.0000000000 0.0000000000 1.0000000000 1.0000000000 N/A 0.2271720677 1.00
test-sequential-v1 a 1 Average Bookings 2000 44400 2308800 22.2000000000 0.0000000000 0.0000000000 25.7272413110 0.6618909455 0.0366471534 0.0000000000 3998.0000000000 1.0000000000 1.0000000000 1.0000000000 1.0000000000 N/A inf 1.00
test-sequential-v1 b 1 Average Bookings 2020 35000 1700000 17.3267326733 -4.8732673267 -0.2195165462 23.2730881112 0.5990824184 0.0308725819 -7.1104045326 3970.1185027169 0.0000000000 0.0000000000 1.0000000000 1.0000000000 N/A inf 1.00
test-sequential-v2 a 1 Average Bookings 6000 133200 6926400 22.2000000000 0.0000000000 0.0000000000 25.7229523651 0.2205567595 0.0211547166 0.0000000000 11998.0000000000 1.0000000000 1.0000000000 1.0000000000 0.9796082526 N/A 0.0490655917 0.9796082526
test-sequential-v2 b 1 Average Bookings 6060 105000 5100000 17.3267326733 -4.8732673267 -0.2195165462 23.2692467167 0.1996278587 0.0178213388 -12.3176237550 11914.3163356925 0.0000000000 0.0000000000 1.0000000000 0.9796082526 N/A 0.0413342977 0.9796082526
test-sequential-v3 a 1 Average Bookings 8000 177600 9235200 22.2000000000 0.0000000000 0.0000000000 25.7224163977 0.1654106763 0.0183201403 0.0000000000 15998.0000000000 1.0000000000 1.0000000000 1.0000000000 0.9500000000 N/A 0.0359095319 0.95
Expand Down
22 changes: 22 additions & 0 deletions tests/epstats/toolkit/test_statistics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
from src.epstats.toolkit.statistics import Statistics


@pytest.mark.parametrize(
"test_length, actual_day, expected",
[
(14, 0, 1.00),
(14, 1, 1.00),
(14, 2, 1.00),
(14, 3, 1.00),
(14, 14, 0.95),
(7, 1, 1.00),
(28, 4, 1.00),
(28, 8, 0.9998),
(28, 28, 0.95),
],
)
def test_obf_alpha_spending_function(test_length, actual_day, expected):

alpha = Statistics.obf_alpha_spending_function(0.95, test_length, actual_day)
assert alpha == expected

0 comments on commit 690bbda

Please sign in to comment.