Module: Apache::Stat::Correlation

Defined in:
lib/ruby-band/apache/stat/correlation.rb

Class Method Summary collapse

Class Method Details

.covariance(array_1, array_2) ⇒ Object

Calculate covariance between two Numeric arrays

  • Args :

    • Array1 -> must be a RubyArray.

    • Array2 -> must be a RubyArray.



15
16
17
18
19
# File 'lib/ruby-band/apache/stat/correlation.rb', line 15

def self.covariance(array_1,array_2)
  obj = Covariance.new
  result = obj.covariance(array_1.to_java(:double),array_2.to_java(:double))
  result
end

.pearson_correlation(array_1, array_2) ⇒ Object

Calculate Pearson correlation between two Numeric arrays

  • Args :

    • Array1 -> must be a RubyArray.

    • Array2 -> must be a RubyArray.



25
26
27
28
29
# File 'lib/ruby-band/apache/stat/correlation.rb', line 25

def self.pearson_correlation(array_1,array_2)
  obj = PearsonsCorrelation.new
  result = obj.correlation(array_1.to_java(:double),array_2.to_java(:double))
  result
end

.spearman_correlation(array_1, array_2) ⇒ Object

Calculate Spearman correlation between two Numeric arrays

  • Args :

    • Array1 -> must be a RubyArray.

    • Array2 -> must be a RubyArray.



35
36
37
38
39
# File 'lib/ruby-band/apache/stat/correlation.rb', line 35

def self.spearman_correlation(array_1,array_2)
  obj = SpearmansCorrelation.new
  result = obj.correlation(array_1.to_java(:double),array_2.to_java(:double))
  result
end