rust 0.2 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rust-basics.rb +126 -0
- data/lib/rust-calls.rb +69 -0
- data/lib/rust-core.rb +303 -99
- data/lib/rust-csv.rb +95 -0
- data/lib/rust-descriptive.rb +3 -3
- data/lib/rust-effsize.rb +14 -14
- data/lib/rust-plots.rb +351 -0
- data/lib/rust-tests.rb +41 -20
- data/lib/rust.rb +5 -0
- metadata +6 -2
data/lib/rust-tests.rb
CHANGED
@@ -41,14 +41,14 @@ module Rust::StatisticalTests::Wilcoxon
|
|
41
41
|
raise "The two distributions have different size" if d1.size != d2.size
|
42
42
|
|
43
43
|
Rust.exclusive do
|
44
|
-
Rust
|
45
|
-
Rust
|
44
|
+
Rust["wilcox.a"] = d1
|
45
|
+
Rust["wilcox.b"] = d2
|
46
46
|
|
47
|
-
_, warnings = Rust._eval("result = wilcox.test(a, b, alternative='two.sided', paired=T)", true)
|
47
|
+
_, warnings = Rust._eval("wilcox.result = wilcox.test(wilcox.a, wilcox.b, alternative='two.sided', paired=T)", true)
|
48
48
|
result = Rust::StatisticalTests::Result.new
|
49
49
|
result.name = "Wilcoxon Signed-Rank test"
|
50
|
-
result.pvalue = Rust._pull("result$p.value")
|
51
|
-
result[:w] = Rust._pull("result$statistic")
|
50
|
+
result.pvalue = Rust._pull("wilcox.result$p.value")
|
51
|
+
result[:w] = Rust._pull("wilcox.result$statistic")
|
52
52
|
result.exact = !warnings.include?("cannot compute exact p-value with zeroes")
|
53
53
|
result.alpha = alpha
|
54
54
|
|
@@ -61,14 +61,14 @@ module Rust::StatisticalTests::Wilcoxon
|
|
61
61
|
raise TypeError, "Expecting Array of numerics" if !d2.is_a?(Array) || !d2.all? { |e| e.is_a?(Numeric) }
|
62
62
|
|
63
63
|
Rust.exclusive do
|
64
|
-
Rust
|
65
|
-
Rust
|
64
|
+
Rust["wilcox.a"] = d1
|
65
|
+
Rust["wilcox.b"] = d2
|
66
66
|
|
67
|
-
_, warnings = Rust._eval("result = wilcox.test(a, b, alternative='two.sided', paired=F)", true)
|
67
|
+
_, warnings = Rust._eval("wilcox.result = wilcox.test(wilcox.a, wilcox.b, alternative='two.sided', paired=F)", true)
|
68
68
|
result = Rust::StatisticalTests::Result.new
|
69
69
|
result.name = "Wilcoxon Ranked-Sum test (a.k.a. Mann–Whitney U test)"
|
70
|
-
result.pvalue = Rust._pull("result$p.value")
|
71
|
-
result[:w] = Rust._pull("result$statistic")
|
70
|
+
result.pvalue = Rust._pull("wilcox.result$p.value")
|
71
|
+
result[:w] = Rust._pull("wilcox.result$statistic")
|
72
72
|
result.exact = !warnings.include?("cannot compute exact p-value with ties")
|
73
73
|
result.alpha = alpha
|
74
74
|
|
@@ -86,14 +86,14 @@ module Rust::StatisticalTests::T
|
|
86
86
|
raise "The two distributions have different size" if d1.size != d2.size
|
87
87
|
|
88
88
|
Rust.exclusive do
|
89
|
-
Rust
|
90
|
-
Rust
|
89
|
+
Rust["t.a"] = d1
|
90
|
+
Rust["t.b"] = d2
|
91
91
|
|
92
|
-
warnings = Rust._eval("result = t.test(a, b, alternative='two.sided', paired=T)")
|
92
|
+
warnings = Rust._eval("t.result = t.test(t.a, t.b, alternative='two.sided', paired=T)")
|
93
93
|
result = Rust::StatisticalTests::Result.new
|
94
94
|
result.name = "Paired t-test"
|
95
|
-
result.pvalue = Rust._pull("result$p.value")
|
96
|
-
result[:t] = Rust._pull("result$statistic")
|
95
|
+
result.pvalue = Rust._pull("t.result$p.value")
|
96
|
+
result[:t] = Rust._pull("t.result$statistic")
|
97
97
|
result.exact = true
|
98
98
|
result.alpha = alpha
|
99
99
|
|
@@ -106,14 +106,14 @@ module Rust::StatisticalTests::T
|
|
106
106
|
raise TypeError, "Expecting Array of numerics" if !d2.is_a?(Array) || !d2.all? { |e| e.is_a?(Numeric) }
|
107
107
|
|
108
108
|
Rust.exclusive do
|
109
|
-
Rust
|
110
|
-
Rust
|
109
|
+
Rust["t.a"] = d1
|
110
|
+
Rust["t.b"] = d2
|
111
111
|
|
112
|
-
Rust._eval("result = t.test(a, b, alternative='two.sided', paired=F)")
|
112
|
+
Rust._eval("t.result = t.test(t.a, t.b, alternative='two.sided', paired=F)")
|
113
113
|
result = Rust::StatisticalTests::Result.new
|
114
114
|
result.name = "Welch Two Sample t-test"
|
115
|
-
result.pvalue = Rust._pull("result$p.value")
|
116
|
-
result[:t] = Rust._pull("result$statistic")
|
115
|
+
result.pvalue = Rust._pull("t.result$p.value")
|
116
|
+
result[:t] = Rust._pull("t.result$statistic")
|
117
117
|
result.exact = true
|
118
118
|
result.alpha = alpha
|
119
119
|
|
@@ -123,6 +123,27 @@ module Rust::StatisticalTests::T
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
+
module Rust::StatisticalTests::Shapiro
|
127
|
+
class << self
|
128
|
+
def compute(vector, alpha = 0.05)
|
129
|
+
raise TypeError, "Expecting Array of numerics" if !vector.is_a?(Array) || !vector.all? { |e| e.is_a?(Numeric) }
|
130
|
+
Rust.exclusive do
|
131
|
+
Rust['shapiro.v'] = vector
|
132
|
+
|
133
|
+
Rust._eval("shapiro.result = shapiro.test(shapiro.v)")
|
134
|
+
result = Rust::StatisticalTests::Result.new
|
135
|
+
result.name = "Shapiro-Wilk normality test"
|
136
|
+
result.pvalue = Rust._pull("shapiro.result$p.value")
|
137
|
+
result[:W] = Rust._pull("shapiro.result$statistic")
|
138
|
+
result.exact = true
|
139
|
+
result.alpha = alpha
|
140
|
+
|
141
|
+
return result
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
126
147
|
module Rust::RBindings
|
127
148
|
def wilcox_test(d1, d2, **args)
|
128
149
|
paired = args[:paired] || false
|
data/lib/rust.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rust
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simone Scalabrino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rinruby
|
@@ -56,9 +56,13 @@ executables: []
|
|
56
56
|
extensions: []
|
57
57
|
extra_rdoc_files: []
|
58
58
|
files:
|
59
|
+
- lib/rust-basics.rb
|
60
|
+
- lib/rust-calls.rb
|
59
61
|
- lib/rust-core.rb
|
62
|
+
- lib/rust-csv.rb
|
60
63
|
- lib/rust-descriptive.rb
|
61
64
|
- lib/rust-effsize.rb
|
65
|
+
- lib/rust-plots.rb
|
62
66
|
- lib/rust-tests.rb
|
63
67
|
- lib/rust.rb
|
64
68
|
homepage: https://github.com/intersimone999/ruby-rust
|