Class: NMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/cass/extensions.rb

Overview

Added functionality in NArray matrix class.

Instance Method Summary collapse

Instance Method Details

#corrObject

Compute and return the column-wise correlation matrix for an NMatrix.



5
6
7
8
9
10
11
12
13
14
# File 'lib/cass/extensions.rb', line 5

def corr
  n = self.shape[0]
  n.times { |i|
    col = self[i,true]
    sd = col.stddev
    self[i,true] = ((col.sbt!(col.mean))/sd).to_a.flatten
  }
  #p self.to_a
  (self.transpose*self)/(self.shape[1]-1).to_f
end