feldtruby 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,9 @@ module MiniTest::Assertions
6
6
  # Ensure that that are (statistically) the same number of each type
7
7
  # of value in an array.
8
8
  def assert_similar_proportions(values, msg = nil)
9
- pvalue = FeldtRuby.probability_of_same_proportions(values)
10
- assert(pvalue >= 0.95, msg || "Proportions differ! p-value that they are the same is #{pvalue} (<0.95)")
9
+ #pvalue = FeldtRuby.probability_of_same_proportions(values)
10
+ pvalue = FeldtRuby.chi_squared_test(values)
11
+ assert(pvalue > 0.05, msg || "Proportions differ! p-value is #{pvalue} (<0.05), counts: #{values.counts.inspect}")
11
12
  end
12
13
  end
13
14
 
@@ -96,6 +96,13 @@ module Statistics
96
96
  res = RC.call("prop.test", vs, ([vs.sum] * vs.length))
97
97
  res.p_value
98
98
  end
99
+
100
+ def chi_squared_test(aryOrHashOfCounts)
101
+ counts = (Hash === aryOrHashOfCounts) ? aryOrHashOfCounts : aryOrHashOfCounts.counts
102
+ vs = counts.values
103
+ res = RC.call("chisq.test", vs)
104
+ res.p_value
105
+ end
99
106
  end
100
107
 
101
108
  # Make them available at top level
@@ -1,3 +1,3 @@
1
1
  module FeldtRuby
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -75,12 +75,12 @@ require 'feldtruby/minitest_extensions'
75
75
 
76
76
  describe "Test Statistics but with the extensions to MiniTest framework" do
77
77
  it "can use assert_same_proportions" do
78
- assert_similar_proportions [1,1,1,1,1, 2,2,2,2,2]
78
+ assert_similar_proportions( [1]*10 + [2]*10 )
79
79
  # This should fail but I found now way to test it since it uses the MiniTest framework itself...
80
80
  # assert_similar_proportions( [1]*60 + [2]*40 )
81
81
  end
82
82
 
83
83
  it "can use must_have_similar_proportions" do
84
- [1,1,1,1,1, 2,2,2,2,2].must_have_similar_proportions
84
+ ([1]*10 + [2]*10).must_have_similar_proportions
85
85
  end
86
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feldtruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: