def MakeNormalPlot(weights): """Generates a normal probability plot of birth weights.""" rankit.MakeNormalPlot( weights, root='nsfg_birthwgt_normal', ylabel='Birth weights (oz)', )
def MakeFigures(): pops = populations.Process() print len(pops) cdf = Cdf.MakeCdfFromList(pops, 'populations') myplot.Cdf(cdf, root='populations', title='City/Town Populations', xlabel='population', ylabel='CDF', legend=False) myplot.Cdf(cdf, root='populations_logx', title='City/Town Populations', xlabel='population', ylabel='CDF', xscale='log', legend=False) myplot.Cdf(cdf, root='populations_loglog', complement=True, title='City/Town Populations', xlabel='population', ylabel='Complementary CDF', yscale='log', xscale='log', legend=False) t = [math.log(x) for x in pops] t.sort() rankit.MakeNormalPlot(t, 'populations_rankit')
def MakeFigures(self): """Generates CDFs and normal prob plots for weights and log weights.""" weights = [record.wtkg2 for record in self.records if record.wtkg2 != 'NA'] self.MakeNormalModel(weights, root='brfss_weight_model') rankit.MakeNormalPlot(weights, root='brfss_weight_normal', title='Adult weight', ylabel='Weight (kg)') log_weights = [math.log(weight) for weight in weights] xmax = math.log(175.0) axis = [3.5, 5.2, 0, 1] self.MakeNormalModel(log_weights, root='brfss_weight_log', xmax=xmax, xlabel='adult weight (log kg)', axis=axis) rankit.MakeNormalPlot(log_weights, root='brfss_weight_lognormal', title='Adult weight', ylabel='Weight (log kg)')
def main(): results = relay.ReadResults() speeds = relay.GetSpeeds(results) rankit.MakeNormalPlot(speeds, root='relay_normal', ylabel='Speed (MPH)')
#生成10个不同随机变量的随机数之和,重复多次,计算其分布 import numpy as np import random import rankit def once(): binomial = np.random.binomial(2, 0.4) poisson = np.random.poisson(2) uniform = random.uniform(1, 10) chisquare = np.random.chisquare(2) normal = np.random.normal(3, 3) lognormal = np.random.lognormal(2, 3) standard_t = np.random.standard_t(2) exponential = np.random.exponential(2) triangular = np.random.triangular(1, 3, 10) beta = np.random.beta(3, 2) gamma = np.random.gamma(3) weibull = np.random.weibull(3) gumbel = np.random.gumbel(3, 2) return ( binomial + poisson + uniform + chisquare + normal + lognormal + standard_t + exponential + triangular + beta + gamma + weibull + gumbel) if __name__ == "__main__": rankit.MakeNormalPlot([once() for i in range(10000)])