Module: Alglib
- Defined in:
- lib/alglib.rb,
lib/alglib/logit.rb,
lib/alglib/correlation.rb,
lib/alglib/linearregression.rb
Defined Under Namespace
Classes: LinearRegression, Logit
Constant Summary collapse
- VERSION =
'1.0.1'
Class Method Summary collapse
- .array_to_real1darray(a) ⇒ Object
-
.pearson_correlation(a, b) ⇒ Object
Retrieves Pearson correlation for two arrays.
-
.pearson_correlation_significance(r, size) ⇒ Object
Retrieves significance for pearson correlation for one or two tails Returns a hash with keys :both, :left and :right.
- .real2darray_to_array(a) ⇒ Object
-
.spearman_correlation(a, b) ⇒ Object
Retrieves Spearman ranked correlation for two arrays Equal to Pearson correlation for ranked data.
- .spearman_correlation_significance(r, size) ⇒ Object
Class Method Details
.array_to_real1darray(a) ⇒ Object
24 25 26 27 28 |
# File 'lib/alglib.rb', line 24 def self.array_to_real1darray(a) v=Alglib_ext::Real1dArray.new Alglib_ext.array_to_real1d(a,v) v end |
.pearson_correlation(a, b) ⇒ Object
Retrieves Pearson correlation for two arrays
3 4 5 6 |
# File 'lib/alglib/correlation.rb', line 3 def self.pearson_correlation(a,b) raise ArgumentError "argument should be the same size" if a.size!=b.size Alglib_ext::pearsoncorrelation(a,b,a.size) end |
.pearson_correlation_significance(r, size) ⇒ Object
Retrieves significance for pearson correlation for one or two tails Returns a hash with keys :both, :left and :right
16 17 18 19 20 |
# File 'lib/alglib/correlation.rb', line 16 def self.pearson_correlation_significance(r,size) out={} out[:both], out[:left], out[:right] = Alglib_ext::pearsoncorrelationsignificance(r, size) out end |
.real2darray_to_array(a) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/alglib.rb', line 30 def self.real2darray_to_array(a) lr=a.getlowbound(1) lc=a.getlowbound(2) hr=a.gethighbound(1) hc=a.gethighbound(2) out=[] (lr..hr).each{|x| row=[] (lc..hc).each{|y| row[y]=a[x,y] } out[x]=row } out end |
.spearman_correlation(a, b) ⇒ Object
Retrieves Spearman ranked correlation for two arrays Equal to Pearson correlation for ranked data
10 11 12 13 |
# File 'lib/alglib/correlation.rb', line 10 def self.spearman_correlation(a,b) raise ArgumentError "argument should be the same size" if a.size!=b.size Alglib_ext::spearmanrankcorrelation(a,b,a.size) end |
.spearman_correlation_significance(r, size) ⇒ Object
21 22 23 24 25 |
# File 'lib/alglib/correlation.rb', line 21 def self.spearman_correlation_significance(r,size) out={} out[:both], out[:left], out[:right] = Alglib_ext::spearmanrankcorrelationsignificance(r, size) out end |