module Rust::StatisticalTests::Shapiro

Public Class Methods

compute(vector, alpha = 0.05, **options) click to toggle source
# File lib/rust-tests.rb, line 260
def compute(vector, alpha = 0.05, **options)
    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(options[:hypothesis])
        
        return result
    end
end