-
-
Save samithaj/d2e506b1424dba494d913013a4776beb to your computer and use it in GitHub Desktop.
Radial Basis Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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