def MakeNormalPlot(weights): """Generates a normal probability plot of birth weights. weights: sequence """ mean, var = thinkbayes2.TrimmedMeanVar(weights, p=0.01) std = math.sqrt(var) xs = [-5, 5] xs, ys = thinkbayes2.FitLine(xs, mean, std) thinkplot.plot(xs, ys, color='0.8', label='model') xs, ys = thinkbayes2.NormalProbability(weights) thinkplot.plot(xs, ys, label='weights')
def MakeNormalModel(weights): """Plots a CDF with a Normal model. weights: sequence """ cdf = thinkbayes2.Cdf(weights, label='weights') mean, var = thinkbayes2.TrimmedMeanVar(weights) std = math.sqrt(var) print('n, mean, std', len(weights), mean, std) xmin = mean - 4 * std xmax = mean + 4 * std xs, ps = thinkbayes2.RenderNormalCdf(mean, std, xmin, xmax) thinkplot.plot(xs, ps, label='model', linewidth=4, color='0.8') thinkplot.cdf(cdf)