module Rust::StatisticalTests::T
Public Class Methods
paired(d1, d2, alpha = 0.05, **options)
click to toggle source
# File lib/rust-tests.rb, line 213 def paired(d1, d2, alpha = 0.05, **options) raise TypeError, "Expecting Array of numerics" if !d1.is_a?(Array) || !d1.all? { |e| e.is_a?(Numeric) } raise TypeError, "Expecting Array of numerics" if !d2.is_a?(Array) || !d2.all? { |e| e.is_a?(Numeric) } raise "The two distributions have different size" if d1.size != d2.size Rust.exclusive do Rust["t.a"] = d1 Rust["t.b"] = d2 warnings = Rust._eval("t.result = t.test(t.a, t.b, alternative='two.sided', paired=T)") result = Rust::StatisticalTests::Result.new result.name = "Paired t-test" result.pvalue = Rust._pull("t.result$p.value") result[:t] = Rust._pull("t.result$statistic") result.exact = true result.alpha = alpha result.hypothesis = Rust::StatisticalTests::Hypothesis.find(options[:hypothesis]) return result end end
unpaired(d1, d2, alpha = 0.05, **options)
click to toggle source
# File lib/rust-tests.rb, line 235 def unpaired(d1, d2, alpha = 0.05, **options) raise TypeError, "Expecting Array of numerics" if !d1.is_a?(Array) || !d1.all? { |e| e.is_a?(Numeric) } raise TypeError, "Expecting Array of numerics" if !d2.is_a?(Array) || !d2.all? { |e| e.is_a?(Numeric) } Rust.exclusive do Rust["t.a"] = d1 Rust["t.b"] = d2 Rust._eval("t.result = t.test(t.a, t.b, alternative='two.sided', paired=F)") result = Rust::StatisticalTests::Result.new result.name = "Welch Two Sample t-test" result.pvalue = Rust._pull("t.result$p.value") result[:t] = Rust._pull("t.result$statistic") result.exact = true result.alpha = alpha result.hypothesis = Rust::StatisticalTests::Hypothesis.find(options[:hypothesis]) return result end end