module Rsquared::Helper
The Helper
module implements uncommon statistical functions directly For use by experts only
Example¶ ↑
Rsquared::Helper::kscv(30)
=> 0.190
Public Class Methods
grubbscv(n, alpha)
click to toggle source
grubbscv(n, alpha) => Float Calculates the Grubbs critical value
# File lib/rsquared.rb, line 50 def grubbscv(n, alpha) tcv = Distribution::T::p_value(alpha/(2*n), n-2) return ((n-1)/Math.sqrt(n))*Math.sqrt(tcv**2/((n-2)+tcv**2)) end
kscv(n)
click to toggle source
kscv(n) => Float Estimates the 5% critical value of the Kolomogorov-Smirnov distribution given sample size
# File lib/rsquared.rb, line 29 def kscv(n) if n < 1 then return 1.0 elsif n < 21 then return KSCV[n-1] elsif n >= 20 and n < 25 then return 0.270 elsif n >= 25 and n < 30 then return 0.240 elsif n >= 30 and n < 35 then return 0.230 elsif n > 35 then return 1.36/Math.sqrt(n) end end
Public Instance Methods
adjustForSided(pvalue, sided)
click to toggle source
Modifies p-value to account for tails and/or two-sided tests
# File lib/rsquared.rb, line 60 def adjustForSided(pvalue, sided) if sided == Upper.tail then return 1.0-pvalue elsif sided == Two.sided then return [(1.0-pvalue)*2.0, pvalue*2.0].min end end
Private Instance Methods
grubbscv(n, alpha)
click to toggle source
grubbscv(n, alpha) => Float Calculates the Grubbs critical value
# File lib/rsquared.rb, line 50 def grubbscv(n, alpha) tcv = Distribution::T::p_value(alpha/(2*n), n-2) return ((n-1)/Math.sqrt(n))*Math.sqrt(tcv**2/((n-2)+tcv**2)) end
kscv(n)
click to toggle source
kscv(n) => Float Estimates the 5% critical value of the Kolomogorov-Smirnov distribution given sample size
# File lib/rsquared.rb, line 29 def kscv(n) if n < 1 then return 1.0 elsif n < 21 then return KSCV[n-1] elsif n >= 20 and n < 25 then return 0.270 elsif n >= 25 and n < 30 then return 0.240 elsif n >= 30 and n < 35 then return 0.230 elsif n > 35 then return 1.36/Math.sqrt(n) end end