Class: Rust::EffectSize::CohenD
Overview
Cohen D effect size statistics.
Class Method Summary collapse
-
.compute(d1, d2) ⇒ Object
Computes and returns the effect size for
d1
andd2
.
Class Method Details
.compute(d1, d2) ⇒ Object
Computes and returns the effect size for d1
and d2
.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rust/stats/effsize.rb', line 67 def self.compute(d1, d2) 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) } if d1.size <= 1 || d2.size <= 1 return Rust::EffectSize::Result.new end Rust.exclusive do Rust['effsize.a'] = d1 Rust['effsize.b'] = d2 Rust._eval("effsize.result = cohen.d(effsize.a, effsize.b)") result = Rust::EffectSize::Result.new result.name = "Cohen's d" result.estimate = Rust._pull("effsize.result$estimate") rescue Float::NAN result.confidence_interval = Range.new(*Rust._pull("effsize.result$conf.int")) rescue nil result.confidence_level = Rust._pull("effsize.result$conf.level") rescue Float::NAN result.magnitude = Rust._pull("as.character(effsize.result$magnitude)").to_sym rescue nil return result end end |