def __init__(self, exam, score): self.exam = exam self.score = score # start with the Normal prior efficacies = thinkbayes2.MakeNormalPmf(0, 1.5, 3) thinkbayes2.Suite.__init__(self, efficacies) # update based on an exam score self.Update(score)
def main(): p1 = thinkbayes2.MakeNormalPmf(0, 1, 3, n=101) p1.label = 'p1' p2 = p1.Copy(label='p2') q1 = thinkbayes2.MakeNormalPmf(0, 1, 3, n=101) q1.label = 'q1' q2 = q1.Copy(label='q2') p1, q1 = Update(p1, q1, True) p1, q2 = Update(p1, q2, True) p2, q1 = Update(p2, q1, True) p2, q2 = Update(p2, q2, False) thinkplot.PrePlot(num=4, rows=2) thinkplot.Pmfs([p1, p2]) thinkplot.Config(legend=True) thinkplot.SubPlot(2) thinkplot.Pmfs([q1, q2]) thinkplot.Show() print('Prob p1 > p2', p1 > p2) print('Prob q1 > q2', q1 > q2)
def __init__(self, label=None): """Initializes the Hockey object. label: string """ if USE_SUMMARY_DATA: # prior based on each team's average goals scored mu = 2.8 sigma = 0.3 else: # prior based on each pair-wise match-up mu = 2.8 sigma = 0.85 pmf = thinkbayes2.MakeNormalPmf(mu, sigma, 4) thinkbayes2.Suite.__init__(self, pmf, label=label)
def CalibrateDifficulty(self): """Make a plot showing the model distribution of raw scores.""" thinkplot.Clf() thinkplot.PrePlot(num=2) cdf = thinkbayes2.Cdf(self.raw, label='data') thinkplot.Cdf(cdf) efficacies = thinkbayes2.MakeNormalPmf(0, 1.5, 3) pmf = self.MakeRawScoreDist(efficacies) cdf = thinkbayes2.Cdf(pmf, label='model') thinkplot.Cdf(cdf) thinkplot.Save(root='sat_calibrate', xlabel='raw score', ylabel='CDF', formats=['pdf', 'eps'])
def main(): # Data of time since last login for >100 observed females femaleData = [ 1, 1, 21, 2, 24, 2, 1, 2, 1, 2, 5, 1, 2, 1, 2, 2, 2, 2, 2.67, 2, 1, 2, 2, 0.08333333333, 3, 2, 24, 336, 11, 3, 10, 1, 0.1833333333, 0.7166666667, 3, 1, 1, 3, 3, 3, 0.15, 3, 3, 3, 48, 1, 72, 2, 2, 0.6, 1, 4, 5, 4, 0.6833333333, 120, 4, 0.4, 4, 4, 72, 3, 24, 0.65, 0.65, 96, 0.5333333333, 1, 2, 2, 6, 3, 1, 3, 720, 7, 6, 24, 0.06666666667, 0.9, 0.06666666667, 0.2, 0.4333333333, 7, 96, 22, 8, 1, 0.4, 48, 0.1, 2, 7, 3, 0.06666666667, 6, 24, 0.4166666667, 9, 720, 8, 1, 9 ] # make the priors (normal distribution) normpmf = thinkbayes2.MakeNormalPmf(10, 10, 4) lampmf = Lambda(label='Thresh=5') for val, prob in normpmf.Items(): if (val >= 0 and val <= 100): lampmf[val] = prob lampmf.Normalize() # thinkplot.Pmf(lampmf) lampmf2 = copy.deepcopy(lampmf) lampmf3 = lampmf.Copy(label='Thresh=10')