Class: Rust::StatisticalTests::Shapiro
- Defined in:
- lib/rust/stats/tests.rb
Overview
Utilities for the Shapiro normality test.
Class Method Summary collapse
-
.compute(vector, alpha = 0.05, **options) ⇒ Object
Runs the Shapiro normality test for
vector
and a givenalpha
(0.05, by default).
Class Method Details
.compute(vector, alpha = 0.05, **options) ⇒ Object
Runs the Shapiro normality test for vector
and a given alpha
(0.05, by default). options
can be specified and directly passed to the R function.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/rust/stats/tests.rb', line 247 def self.compute(vector, alpha = 0.05, **) raise TypeError, "Expecting Array of numerics" if !vector.is_a?(Array) || !vector.all? { |e| e.is_a?(Numeric) } Rust.exclusive do Rust['shapiro.v'] = vector Rust._eval("shapiro.result = shapiro.test(shapiro.v)") result = Rust::StatisticalTests::Result.new result.name = "Shapiro-Wilk normality test" result.pvalue = Rust._pull("shapiro.result$p.value") result[:W] = Rust._pull("shapiro.result$statistic") result.exact = true result.alpha = alpha result.hypothesis = Rust::StatisticalTests::Hypothesis.find([:hypothesis]) return result end end |