Esempio n. 1
0
def main():
    results = ReadResults()
    print '# of samples:', len(results)

    results = CondFilter(results)
    print '# of samples(age=30s):', len(results)

    h_speed, h_rank, h_rank_age = FindProfHeo(results)
    speeds = GetSpeeds(results)
    pmf = Pmf.MakePmfFromList(speeds, 'speeds')
    cdf = Cdf.MakeCdfFromList(speeds, 'speeds')
    if h_speed:
        print '허준영s speed is ', h_speed
        print 'His percentile rank is ', cdf.Prob(h_speed) * 100

    myplot.Clf()
    myplot.Pmf(pmf)
    myplot.Save(root='mbc_marathon_pmf',
                title='PMF of running speed',
                xlabel='speed (kmh)',
                ylabel='probability')

    myplot.Clf()
    myplot.Cdf(cdf)
    myplot.Save(root='mbc_marathon_cdf',
                title='CDF of running speed',
                xlabel='speed (kmh)',
                ylabel='probability')

    myplot.Close()
Esempio n. 2
0
def MakeFigures(pool):
    myplot.Clf()
    myplot.Hist(pool.weight_pmf, linewidth=1, color='blue')
    myplot.Save(root='nsfg_birthwgt_pmf',
                title='Birth weight PMF',
                xlabel='weight (ounces)',
                ylabel='probability')

    myplot.Clf()
    myplot.Cdf(pool.lengths_pmf, linewidth=1, color='blue')
    myplot.Save(root='nsfg_weeks_pmf',
                title='Gestation PMF',
                xlabel='weeks',
                ylabel='probability')
Esempio n. 3
0
def ex6_14(n, do_log=False, ns=1000):
    exp = randvar.Exponential(1)

    def prod_log(t):
        p = 1
        for x in t:
            p = p * x

        if do_log == True:
            return math.log(p)
        else:
            return p

    s = [prod_log([exp.generate() for x in range(n)]) for i in range(ns)]

    mu, var = thinkstats.MeanVar(s)
    print n, mu, var

    cdf = Cdf.MakeCdfFromList(s)
    myplot.Clf()
    myplot.Cdf(cdf)
    myplot.Save('clt14' + str(do_log) + str(n))

    rankit.MakeNormalPlot(s, 'clt14npp' + str(do_log) + str(n))

    myplot.Close()
Esempio n. 4
0
def ex6_12(n, ns=1000):
    exp = randvar.Exponential(1)

    s = [sum([exp.generate() for x in range(n)]) / float(n) for i in range(ns)]

    mu, var = thinkstats.MeanVar(s)
    print n, mu, var

    cdf = Cdf.MakeCdfFromList(s)
    myplot.Clf()
    myplot.Cdf(cdf)
    myplot.Save('clt' + str(n))
    myplot.Close()
Esempio n. 5
0
def ex6_13(n, ns=1000):
    exp = randvar.Exponential(1)

    s = [sum([exp.generate() for x in range(n)]) for i in range(ns)]

    mu, var = thinkstats.MeanVar(s)
    print n, mu, var

    cdf = Cdf.MakeCdfFromList(s)
    myplot.Clf()
    myplot.Cdf(cdf)
    myplot.Save('clt13' + str(n))

    rankit.MakeNormalPlot(s, 'clt13npp' + str(n))

    myplot.Close()
Esempio n. 6
0
26	,
23	,
14	,
101	,
125	,
0	,
53	,
10	,
56	,
165	,
46	,
5	,
0	,
38	,
29	,
4	,
30	,
89	,
14	,
                    ]

cdf = Cdf.MakeCdfFromList(birthday_arrival)
print 'Mean:', cdf.Mean()
myplot.Clf()
myplot.Cdf(cdf)
myplot.Save('birthday_cdf')
myplot.Clf()
myplot.Cdf(cdf, complement=True)
myplot.Save('birthday_ccdf', yscale='log')
myplot.Close()