Class: Rsquared::PropTest
Instance Attribute Summary
Attributes inherited from StatTest
Instance Method Summary collapse
-
#initialize(data, p0, sided) ⇒ PropTest
constructor
A new instance of PropTest.
-
#statistic ⇒ Object
Returns the z-statistic.
Methods inherited from StatTest
#inspect, #setSidedness!, #significant?
Constructor Details
#initialize(data, p0, sided) ⇒ PropTest
Returns a new instance of PropTest.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/Rsquared/PropTest.rb', line 4 def initialize(data, p0, sided) @data = data @p0 = p0 @sided = sided if (@data.length*@p0 < 10.0) or (@data.length*(1.0-@p0) < 10.0) then raise AssumptionError, "The number of successes or failures prediced by the proportion is too small" end @stderr = Math.sqrt((@p0*(1.0-@p0))/@data.length) @pstat = ((@data.sum.to_f/@data.length.to_f) - @p0)/@stderr @pvalue = Distribution::Normal::cdf(@pstat) self.setSidedness!(@sided) end |
Instance Method Details
#statistic ⇒ Object
Returns the z-statistic
23 24 25 |
# File 'lib/Rsquared/PropTest.rb', line 23 def statistic @pstat end |