コード例 #1
0
ファイル: paintball.py プロジェクト: junghh21/ThinkBayes2-1
def MakePosteriorPlot(suite):
    """Plots the posterior marginal distributions for alpha and beta.

    suite: posterior joint distribution of location
    """
    marginal_alpha = suite.Marginal(0)
    marginal_alpha.name = 'alpha'
    marginal_beta = suite.Marginal(1)
    marginal_beta.name = 'beta'

    print('alpha CI', marginal_alpha.CredibleInterval(50))
    print('beta CI', marginal_beta.CredibleInterval(50))

    thinkplot.PrePlot(num=2)

    #thinkplot.Pmf(marginal_alpha)
    #thinkplot.Pmf(marginal_beta)
    
    thinkplot.Cdf(thinkbayes2.MakeCdfFromPmf(marginal_alpha))
    thinkplot.Cdf(thinkbayes2.MakeCdfFromPmf(marginal_beta))
    
    thinkplot.Save('paintball2',
                xlabel='Distance',
                ylabel='Prob',
                loc=4,
                formats=FORMATS)
コード例 #2
0
 def addTeam(self, team, this_team, rest_of_league):
     this_x_cdf = tb.MakeCdfFromPmf(tb.MakePmfFromList(this_team.X_unadj))
     this_y_cdf = tb.MakeCdfFromPmf(tb.MakePmfFromList(this_team.Y_unadj))
     other_x_cdf = tb.MakeCdfFromPmf(
         tb.MakePmfFromList(rest_of_league.X_unadj))
     other_y_cdf = tb.MakeCdfFromPmf(
         tb.MakePmfFromList(rest_of_league.Y_unadj))
     self.addCDFs(team, this_x_cdf, this_y_cdf, other_x_cdf, other_y_cdf)
コード例 #3
0
ファイル: variability.py プロジェクト: qrsforever/workspace
def PlotCoefVariation(suites):
    """Plot the posterior distributions for CV.

    suites: map from label to Pmf of CVs.
    """
    thinkplot.Clf()
    thinkplot.PrePlot(num=2)

    pmfs = {}
    for label, suite in suites.items():
        pmf = CoefVariation(suite)
        print('CV posterior mean', pmf.Mean())
        cdf = thinkbayes2.MakeCdfFromPmf(pmf, label)
        thinkplot.Cdf(cdf)

        pmfs[label] = pmf

    thinkplot.Save(root='variability_cv',
                   xlabel='Coefficient of variation',
                   ylabel='Probability')

    print('female bigger',
          thinkbayes2.PmfProbGreater(pmfs['female'], pmfs['male']))
    print('male bigger',
          thinkbayes2.PmfProbGreater(pmfs['male'], pmfs['female']))
コード例 #4
0
ファイル: variability.py プロジェクト: qrsforever/workspace
def PlotMarginals(suite):
    """Plots marginal distributions from a joint distribution.

    suite: joint distribution of mu and sigma.
    """
    thinkplot.Clf()

    pyplot.subplot(1, 2, 1)
    pmf_m = suite.Marginal(0)
    cdf_m = thinkbayes2.MakeCdfFromPmf(pmf_m)
    thinkplot.Cdf(cdf_m)

    pyplot.subplot(1, 2, 2)
    pmf_s = suite.Marginal(1)
    cdf_s = thinkbayes2.MakeCdfFromPmf(pmf_s)
    thinkplot.Cdf(cdf_s)

    thinkplot.Show()