Class: Rsquared::GrubbsTest
- Inherits:
-
Object
- Object
- Rsquared::GrubbsTest
- 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
-
#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
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
#inspect ⇒ Object
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
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 |
#statistic ⇒ Object
Returns the test statistic as a float
105 106 107 |
# File 'lib/rsquared.rb', line 105 def statistic @gstat end |