class Rsquared::PropTest
Public Class Methods
new(data, p0, sided)
click to toggle source
# 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
Public Instance Methods
statistic()
click to toggle source
Returns the z-statistic
# File lib/Rsquared/PropTest.rb, line 23 def statistic @pstat end