diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-09-04 09:49:34 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-09-04 09:49:34 +0100 |
commit | 95afa296f8989ac691df24cc28a963c06a4c86e3 (patch) | |
tree | b1b80813f963ee4a417b05d4bb4d012648d30dff /spec/lib/confidence_intervals.rb | |
parent | 05f9fca1fb2161e078429b6a1f3796a0bf13eade (diff) | |
parent | 4656b24591593bdf5521030ce6bdf68baec6d160 (diff) |
Merge branch 'body-statistics' into rails-3-develop
Diffstat (limited to 'spec/lib/confidence_intervals.rb')
-rw-r--r-- | spec/lib/confidence_intervals.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/lib/confidence_intervals.rb b/spec/lib/confidence_intervals.rb new file mode 100644 index 000000000..cb8717f3d --- /dev/null +++ b/spec/lib/confidence_intervals.rb @@ -0,0 +1,30 @@ +require 'confidence_intervals' + +describe "ci_bounds" do + + describe "when passed all successes" do + it "should never return a high CI above 1" do + ci = ci_bounds 16, 16, 0.01 + ci[1].should be <= 1 + end + end + + describe "when passed all failures" do + it "should never return a low CI below 0" do + ci = ci_bounds 0, 10, 0.05 + ci[0].should be >= 0 + end + end + + describe "when passed 4 out of 10 successes (with 0.05 power)" do + it "should return the correct Wilson's interval" do + # The expected results here were taken from an online + # calculator: + # http://www.vassarstats.net/prop1.html + ci = ci_bounds 7, 10, 0.05 + ci[0].should be_within(0.001).of(0.3968) + ci[1].should be_within(0.001).of(0.8922) + end + end + +end |