142 STATISTICS IS EASY!
lower_bound = int(math.ceil(num_resamples * tails))
upper_bound = int(math.floor(num_resamples * (1 - tails)))
# bias-corrected confidence interval computations
p = num_below_observed / float(num_resamples)# proportion of bootstrap values below
the observed value
dist_from_center = p - .5# if this is negative, the original is below the center, if
positive, it is above
z_0 = area_to_sd(dist_from_center)
# now we want to find the proportion that should be between the mean and one of the
tails
tail_sds = area_to_sd(conf_interval / 2)
z_alpha_over_2 = 0 - tail_sds
z_1_minus_alpha_over_2 = tail_sds
# in case our lower and upper bounds are not integers,
# we decrease the range (the values we include in our interval),
# so that we can keep the same level of confidence
bias_corr_lower_bound = int(math.ceil(num_resamples * (0.5 +
sd_to_area(z_alpha_over_2 + (2 * z_0)))))
bias_corr_upper_bound = int(math.floor(num_resamples * (0.5 +
sd_to_area(z_1_minus_alpha_over_2 + (2 * z_0)))))
######################################
#
# Output
#
######################################
# print observed value and then confidence interval
print "Observed r: %.2f" % observed_r
print "We have ", conf_interval * 100, "% confidence that the true r",
print "is between: %.2f" % out[lower_bound], "and %.2f" % out[upper_bound]
print "***** Bias Corrected Confidence Interval *****"
print "We have", conf_interval * 100, "% confidence that the true r",
print "is between: %.2f" % out[bias_corr_lower_bound], "and %.2f" %
out[bias_corr_upper_bound]
machineANOVAcs.vals
>push button
802.5 1018.0 913.0 822.0 868.5 1087.0 530.0 191.0 1070.0 576.0 769.5 598.0 1033.0
861.5 1.0 363.0 650.0 947.0 932.0 907.0 802.5 966.0 844.0 842.5 988.0 1076.0 765.0
652.0 464.5 1061.0 594.0 379.5 590.0 254.0 321.0 46.0 745.0 726.5 373.0 537.5 568.0
586.0 458.0 274.0 143.0 372.0 173.0 430.5 545.0 531.0 471.0 235.0 433.0 298.5 379.5
438.0 713.0 589.0 104.0 222.0 206.0 185.0 155.0 135.0 174.0 343.0 396.5 468.0 110.0
435.0 341.5 269.0 777.0 928.0 889.5 1093.0 917.0 802.5 241.0 1259.0 282.0 242.0 912.0
26.0 324.0 551.0 443.0 13.0 99.0 323.0 712.0 53.0 194.0 773.0 484.0 123.0 8.0 489.0
76.0 486.0 846.0 746.5 840.5 1037.0 998.0 1049.0 970.0 887.0 479.0 977.0 1133.0 379.5
520.0 464.5 839.0 785.0 159.0 508.0 44.0 893.5 631.0 898.0 148.5 461.0 341.5 518.0
722.0 158.0 436.0 305.0 817.5 344.0 203.0 456.0 899.5 463.0 583.5 349.0 971.5 501.0

Get Statistics is Easy! now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.