Skip to content

Instantly share code, notes, and snippets.

@tbertelsen
tbertelsen / pearson.scala
Last active February 28, 2021 22:14 — forked from kaja47/pearson.scala
Calculating pearson for Breeze vectors
import breeze.linalg._
import breeze.stats._
import scala.math.sqrt
/**
* Effecient for sparse vectors. Scales in O(activeSize)
*/
// Must take SparseVector, for implicits to be linked correctly
def pearson(a: SparseVector[Double], b: SparseVector[Double]): Double = {