Class: Rsquared::GrubbsTest
- Inherits:
-
Object
- Object
- Rsquared::GrubbsTest
- Defined in:
- lib/Rsquared/GrubbsTest.rb
Overview
Tests for outliers on either side of the data grubbs = Rsquared::GrubbsTest.new(data) grubbs.significant? => Boolean
Instance Method Summary collapse
-
#initialize(data) ⇒ GrubbsTest
constructor
Initializes the Test object with an array of numerical data.
- #inspect ⇒ Object
-
#significant?(alpha = 0.05) ⇒ Boolean
(also: #outlier?)
Returns a boolean indicating the significance of the test at the 5% level.
-
#statistic ⇒ Object
Returns the test statistic as a float.
Constructor Details
#initialize(data) ⇒ GrubbsTest
Initializes the Test object with an array of numerical data
13 14 15 16 |
# 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 |
Instance Method Details
#inspect ⇒ Object
30 31 32 |
# File 'lib/Rsquared/GrubbsTest.rb', line 30 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
22 23 24 25 26 27 28 |
# 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 |
#statistic ⇒ Object
Returns the test statistic as a float
38 39 40 |
# File 'lib/Rsquared/GrubbsTest.rb', line 38 def statistic @gstat end |