class Rsquared::GrubbsTest

Tests for outliers on either side of the data grubbs = Rsquared::GrubbsTest.new(data) grubbs.significant? => Boolean

Public Class Methods

new(data) click to toggle source

Initializes the Test object with an array of numerical data

# File lib/Rsquared/GrubbsTest.rb, line 13
def initialize(data)
   @data = data.sort
   @gstat = [((@data.mean - @data.min)/@data.stddev).abs, ((@data.mean - @data.max)/@data.stddev).abs].max
end

Public Instance Methods

inspect() click to toggle source
# File lib/Rsquared/GrubbsTest.rb, line 30
def inspect
    significant?
end
outlier?(alpha=0.05)
Alias for: significant?
significant?(alpha=0.05) click to toggle source

Returns a boolean indicating the significance of the test at the 5% level

# File lib/Rsquared/GrubbsTest.rb, line 22
def significant?(alpha=0.05)
   if @gstat > Helper::grubbscv(@data.length, alpha) then
     return true
   else
      return false
   end
end
Also aliased as: outlier?
statistic() click to toggle source

Returns the test statistic as a float

# File lib/Rsquared/GrubbsTest.rb, line 38
def statistic
    @gstat
end