diff options
author | Mark Longair <mhl@pobox.com> | 2013-08-12 11:57:27 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-08-20 12:11:39 +0100 |
commit | 89e7318805b09cf32c4f919f2b09f522830fb9ec (patch) | |
tree | 4d327e3ad9c804694167419d3818e86e6deae325 /spec/lib/confidence_intervals.rb | |
parent | 1e35677d3c107100200d70d5f506ef2211a92753 (diff) |
Add a page with experimental statistics on public bodies
The statistics on the status of the requests to a particular
public body are too slow to calculate on-the-fly, so this
commit adds:
* Extra columns on public_bodies to store counts of
the successful, not held, and overdue request counts
for each public body.
* A rake task which should be run periodically to update
the overdue request count column.
If Javascript is not available, the summary statistics are
shown as tables. If Javascript is available, graphs are
drawn with Flot.
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 |