Class NMatrix

  1. cass/lib/cass/extensions.rb
Parent: Object

Added functionality in NArray matrix class.

Methods

public instance

  1. corr

Public instance methods

corr ()

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

[show source]
# File cass/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