Module: Rsquared::Helper

Defined in:
lib/rsquared.rb

Overview

The Helper module implements uncommon statistical functions directly For use by experts only

Example

Rsquared::Helper::kscv(30) => 0.190

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.grubbscv(n, alpha) ⇒ Object

grubbscv(n, alpha) => Float Calculates the Grubbs critical value



50
51
52
53
# 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) ⇒ Object

kscv(n) => Float Estimates the 5% critical value of the Kolomogorov-Smirnov distribution given sample size



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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

Instance Method Details

#adjustForSided(pvalue, sided) ⇒ Object

Modifies p-value to account for tails and/or two-sided tests



60
61
62
63
64
65
66
# 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