Module: Rust::RBindings
- Defined in:
- lib/rust/core/csv.rb,
lib/rust/core/rust.rb,
lib/rust/plots/core.rb,
lib/rust/stats/tests.rb,
lib/rust/models/anova.rb,
lib/rust/stats/effsize.rb,
lib/rust/models/regression.rb,
lib/rust/stats/correlation.rb,
lib/rust/stats/descriptive.rb
Instance Method Summary collapse
- #aov(formula, data, **options) ⇒ Object
- #boxplot(*args, **options) ⇒ Object
- #cliff_delta(d1, d2) ⇒ Object
- #cohen_d(d1, d2, **args) ⇒ Object
- #cor(d1, d2, **options) ⇒ Object
- #cor_test(d1, d2, **options) ⇒ Object
- #data_frame(*args) ⇒ Object
- #lm(formula, data, **options) ⇒ Object
- #lmer(formula, data, **options) ⇒ Object
- #mean(series) ⇒ Object
- #median(series) ⇒ Object
- #plot(x, y = (1..x.size).to_a, **options) ⇒ Object
- #quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) ⇒ Object
- #read_csv(filename, **options) ⇒ Object
- #sd(series) ⇒ Object
- #t_test(d1, d2, **args) ⇒ Object
- #var(series) ⇒ Object
- #wilcox_test(d1, d2, **args) ⇒ Object
- #write_csv(filename, dataframe, **options) ⇒ Object
Instance Method Details
#aov(formula, data, **options) ⇒ Object
57 58 59 |
# File 'lib/rust/models/anova.rb', line 57 def aov(formula, data, **) return ANOVAModel.generate(formula, data, **) end |
#boxplot(*args, **options) ⇒ Object
272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/rust/plots/core.rb', line 272 def boxplot(*args, **) result = Rust::Plots::BoxPlot.new .each do |k, v| result[k] = v end result. args.each do |s| result.series(s) end result.show end |
#cliff_delta(d1, d2) ⇒ Object
74 75 76 |
# File 'lib/rust/stats/effsize.rb', line 74 def cliff_delta(d1, d2) Rust::EffectSize::CliffDelta.compute(d1, d2) end |
#cohen_d(d1, d2, **args) ⇒ Object
78 79 80 |
# File 'lib/rust/stats/effsize.rb', line 78 def cohen_d(d1, d2, **args) Rust::EffectSize::CohenD.compute(d1, d2) end |
#cor(d1, d2, **options) ⇒ Object
116 117 118 |
# File 'lib/rust/stats/correlation.rb', line 116 def cor(d1, d2, **) return cor_test(d1, d2, **).correlation end |
#cor_test(d1, d2, **options) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/rust/stats/correlation.rb', line 120 def cor_test(d1, d2, **) method = [:method].to_s.downcase if "pearson".start_with?(method) return Rust::Correlation::Pearson.test(d1, d2) elsif "spearman".start_with?(method) return Rust::Correlation::Spearman.test(d1, d2) elsif "kendall".start_with?(method) return Rust::Correlation::Kendall.test(d1, d2) else raise "Unsupported method #{method}" end end |
#data_frame(*args) ⇒ Object
140 141 142 |
# File 'lib/rust/core/rust.rb', line 140 def data_frame(*args) Rust::DataFrame.new(*args) end |
#lm(formula, data, **options) ⇒ Object
188 189 190 191 |
# File 'lib/rust/models/regression.rb', line 188 def lm(formula, data, **) independent = formula.right_part.split("+").map { |v| v.strip } return LinearRegressionModel.generate(formula.left_part, independent, data, **) end |
#lmer(formula, data, **options) ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/rust/models/regression.rb', line 193 def lmer(formula, data, **) independent = formula.right_part.split("+").map { |v| v.strip } RegressionModel.generate( LinearMixedEffectsModel, "lmer", formula.left_part, independent, data, ** ) end |
#mean(series) ⇒ Object
109 110 111 |
# File 'lib/rust/stats/descriptive.rb', line 109 def mean(series) Rust::Descriptive.mean(series) end |
#median(series) ⇒ Object
113 114 115 |
# File 'lib/rust/stats/descriptive.rb', line 113 def median(series) Rust::Descriptive.median(series) end |
#plot(x, y = (1..x.size).to_a, **options) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/rust/plots/core.rb', line 260 def plot(x, y=(1..x.size).to_a, **) result = Rust::Plots::ScatterPlot.new(x, y) .each do |k, v| result[k] = v end result. result.show end |
#quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) ⇒ Object
125 126 127 |
# File 'lib/rust/stats/descriptive.rb', line 125 def quantile(series, percentiles = [0.0, 0.25, 0.5, 0.75, 1.0]) Rust::Descriptive.quantile(series, percentiles) end |
#read_csv(filename, **options) ⇒ Object
98 99 100 |
# File 'lib/rust/core/csv.rb', line 98 def read_csv(filename, **) Rust::CSV.read(filename, **) end |
#sd(series) ⇒ Object
121 122 123 |
# File 'lib/rust/stats/descriptive.rb', line 121 def sd(series) Rust::Descriptive.standard_deviation(series) end |
#t_test(d1, d2, **args) ⇒ Object
284 285 286 287 288 289 290 291 |
# File 'lib/rust/stats/tests.rb', line 284 def t_test(d1, d2, **args) paired = args[:paired] || false if paired return Rust::StatisticalTests::T.paired(d1, d2) else return Rust::StatisticalTests::T.unpaired(d1, d2) end end |
#var(series) ⇒ Object
117 118 119 |
# File 'lib/rust/stats/descriptive.rb', line 117 def var(series) Rust::Descriptive.variance(series) end |
#wilcox_test(d1, d2, **args) ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/rust/stats/tests.rb', line 275 def wilcox_test(d1, d2, **args) paired = args[:paired] || false if paired return Rust::StatisticalTests::Wilcoxon.paired(d1, d2) else return Rust::StatisticalTests::Wilcoxon.unpaired(d1, d2) end end |
#write_csv(filename, dataframe, **options) ⇒ Object
102 103 104 |
# File 'lib/rust/core/csv.rb', line 102 def write_csv(filename, dataframe, **) Rust::CSV.write(filename, dataframe, **) end |