Module: Rust::StatisticalTests::T
- Defined in:
- lib/rust-tests.rb
Class Method Summary collapse
Class Method Details
.paired(d1, d2, alpha = 0.05) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rust-tests.rb', line 83 def paired(d1, d2, alpha = 0.05) 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 return result end end |
.unpaired(d1, d2, alpha = 0.05) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rust-tests.rb', line 104 def unpaired(d1, d2, alpha = 0.05) 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 return result end end |