Пример #1
0
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']))
Пример #2
0
    def Update(self, data):
        a_sat, b_sat = data

        a_like = thinkbayes2.PmfProbGreater(a_sat, b_sat)
        b_like = thinkbayes2.PmfProbLess(a_sat, b_sat)
        c_like = thinkbayes2.PmfProbEqual(a_sat, b_sat)

        a_like += c_like / 2
        b_like += c_like / 2

        self.Mult('A', a_like)
        self.Mult('B', b_like)

        self.Normalize()
Пример #3
0
def ComparePosteriorPredictive(a_sat, b_sat):
    """Compares the predictive distributions of raw scores.

    a_sat: posterior distribution
    b_sat:
    """
    a_pred = a_sat.MakePredictiveDist()
    b_pred = b_sat.MakePredictiveDist()

    #thinkplot.Clf()
    #thinkplot.Pmfs([a_pred, b_pred])
    #thinkplot.Show()

    a_like = thinkbayes2.PmfProbGreater(a_pred, b_pred)
    b_like = thinkbayes2.PmfProbLess(a_pred, b_pred)
    c_like = thinkbayes2.PmfProbEqual(a_pred, b_pred)

    print('Posterior predictive')
    print('A', a_like)
    print('B', b_like)
    print('C', c_like)