Class: Rsquared::GrubbsTest

Inherits:
Object
  • Object
show all
Defined in:
lib/rsquared.rb

Overview

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ GrubbsTest

Initializes the Test object with an array of numerical data



80
81
82
83
# File 'lib/rsquared.rb', line 80

def initialize(data)
   @data = data.sort
	     @gstat = [((@data.mean - @data.min)/@data.stddev).abs, ((@data.mean - @data.max)/@data.stddev).abs].max
end

Instance Method Details

#inspectObject



97
98
99
# File 'lib/rsquared.rb', line 97

def inspect
    significant?
end

#significant?(alpha = 0.05) ⇒ Boolean Also known as: outlier?

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

Returns:

  • (Boolean)


89
90
91
92
93
94
95
# File 'lib/rsquared.rb', line 89

def significant?(alpha=0.05)
   if @gstat > Helper::grubbscv(@data.length, alpha) then
   	return true
   else
		return false
   end
end

#statisticObject

Returns the test statistic as a float



105
106
107
# File 'lib/rsquared.rb', line 105

def statistic
    @gstat
end