You are here

function SparseVector::covariance in Recommender API 6.2

Same name and namespace in other branches
  1. 7.6 classes/Matrix.php \SparseVector::covariance()

Compute covariance with $vector. No caching option. Works for RealVector. SparseVector needs additional handling.

Parameters

$vector it has to be the same type (either SparseVector or RealVector) as $this:

Return value

covariance value

Overrides Vector::covariance

File

./Matrix.php, line 322

Class

SparseVector
Sparse Vector takes care of missing data.

Code

function covariance(&$vector) {
  $subset = $this
    ->common_items($vector);
  return $subset === NULL ? NAN : $subset[0]
    ->covariance($subset[1]);
}