def plotOutliers(samples): """Make CDFs showing the distribution of outliers.""" cdfs = [] for label, sample in samples.iteritems(): outliers = [x for x in sample if x < 150] cdf = thinkbayes.makeCdfFromList(outliers, label) cdfs.append(cdf) thinkplot.clf() thinkplot.cdfs(cdfs) thinkplot.save(root='variability_cdfs', title='CDF of height', xlabel='Reported height (cm)', ylabel='CDF')
def plotPosteriors(self, other): """Plots posterior distributions of efficacy. self, other: Sat objects. """ thinkplot.clf() thinkplot.prePlot(num=2) cdf1 = thinkbayes.makeCdfFromPmf(self, 'posterior %d' % self.score) cdf2 = thinkbayes.makeCdfFromPmf(other, 'posterior %d' % other.score) thinkplot.cdfs([cdf1, cdf2]) thinkplot.save(xlabel='efficacy', ylabel='CDF', axis=[0, 4.6, 0.0, 1.0], root='sat_5_posteriors_eff', formats=['pdf'])
def makePlot(self, root='redline1'): """Plot the prior and posterior CDF of passengers arrival rate. root: string """ thinkplot.clf() thinkplot.prePlot(2) # convert units to passengers per minute prior = self.priorLambda.makeCdf().scale(60) post = self.posteriorLambda.makeCdf().scale(60) thinkplot.cdfs([prior, post]) thinkplot.save(root=root, xlabel='Arrival rate (passengers / min)', ylabel='CDF', formats=FORMATS)
def makePlot(self, root='redline3'): """Plot the CDFs. root: string """ # observed gaps cdf_prior_x = self.prior_x.makeCdf() cdf_post_x = self.post_x.makeCdf() cdf_y = self.pmf_y.makeCdf() cdfs = scaleDists([cdf_prior_x, cdf_post_x, cdf_y], 1.0 / 60) thinkplot.clf() thinkplot.prePlot(3) thinkplot.cdfs(cdfs) thinkplot.save(root=root, xlabel='Time (min)', ylabel='CDF', formats=FORMATS)
def makePlot(self, root='redline2'): """Plots the computed CDFs. root: string """ print('Mean z', self.pmf_z.mean() / 60) print('Mean zb', self.pmf_zb.mean() / 60) print('Mean y', self.pmf_y.mean() / 60) cdf_z = self.pmf_z.makeCdf() cdf_zb = self.pmf_zb.makeCdf() cdf_y = self.pmf_y.makeCdf() cdfs = scaleDists([cdf_z, cdf_zb, cdf_y], 1.0 / 60) thinkplot.clf() thinkplot.prePlot(3) thinkplot.cdfs(cdfs) thinkplot.save(root=root, xlabel='Time (min)', ylabel='CDF', formats=FORMATS)
def makePlots(player1, player2): """Generates two plots. price1 shows the priors for the two players price2 shows the distribution of diff for the two players """ # plot the prior distribution of price for both players thinkplot.clf() thinkplot.prePlot(num=2) pmf1 = player1.pmfPrice() pmf1.name = 'showcase 1' pmf2 = player2.pmfPrice() pmf2.name = 'showcase 2' thinkplot.pmfs([pmf1, pmf2]) thinkplot.save(root='price1_showcase1,2_priorPmfs', xlabel='price ($)', ylabel='PDF', formats=FORMATS) # plot the historical distribution of underness for both players thinkplot.clf() thinkplot.prePlot(num=2) cdf1 = player1.cdfDiff() cdf1.name = 'player 1' cdf2 = player2.cdfDiff() cdf2.name = 'player 2' print('\n\nPlayer median', cdf1.percentile(50)) print('Player median', cdf2.percentile(50)) print('\nPlayer 1 overbids', player1.probOverbid()) print('Player 2 overbids', player2.probOverbid()) thinkplot.cdfs([cdf1, cdf2]) thinkplot.save(root='price2_diffs_cdf', xlabel='diff ($)', ylabel='CDF', formats=FORMATS)