Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code improvements #44

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions estimators/bandits/gaussian.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
from estimators.bandits import base
from scipy import stats

class Interval(base.Interval):

Expand Down Expand Up @@ -29,14 +30,10 @@ def get(self, alpha=0.05):
SoS = self.data['SoS']

if SoS > 0.0 and den > 1:
zGaussianCdf = {
0.25: 1.15,
0.1: 1.645,
0.05: 1.96
}
zGaussianCdf = stats.norm.ppf(1-alpha/2)

variance = (SoS - num * num / den) / (den - 1)
gaussDelta = zGaussianCdf[alpha] * math.sqrt(variance/den)
gaussDelta = zGaussianCdf * math.sqrt(variance/den)
bounds.append(num / den - gaussDelta)
bounds.append(num / den + gaussDelta)

Expand Down
9 changes: 3 additions & 6 deletions estimators/slates/gaussian.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
from estimators.slates import base
from scipy import stats

class Interval(base.Interval):
def __init__(self):
Expand Down Expand Up @@ -35,14 +36,10 @@ def get(self, alpha=0.05):
SoS = self.data['SoS']

if SoS > 0.0:
zGaussianCdf = {
0.25: 1.15,
0.1: 1.645,
0.05: 1.96
}
zGaussianCdf = stats.norm.ppf(1-alpha/2)

variance = (SoS - num * num / den) / (den - 1)
gaussDelta = zGaussianCdf[alpha] * math.sqrt(variance/den)
gaussDelta = zGaussianCdf * math.sqrt(variance/den)
bounds.append(num / den - gaussDelta)
bounds.append(num / den + gaussDelta)

Expand Down