Skip to content

Instantly share code, notes, and snippets.

@micrypt
Created August 3, 2011 21:14
Show Gist options
  • Save micrypt/1123788 to your computer and use it in GitHub Desktop.
Save micrypt/1123788 to your computer and use it in GitHub Desktop.
Radial Basis Function
import scala.math.{E, pow}
// Vector length
def vecLength(implicit values: List[Double]) = pow(values.sum, .5)
// Radial basis function
def rbf(v1: List[Double], v2: List[Double], gamma:Int = 20) = {
val dv = { for(i <- (0 to v1.length)) yield (v1(i)-v2(i)) }.toList
val l = vecLength(dv)
pow(E, (-gamma*l))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment