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.

Revisions

  1. micrypt revised this gist Aug 3, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion radialBasis.scala
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ 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 <- (1 to v1.length)) yield (v1(i)-v2(i)) }.toList
    val dv = { for(i <- (0 to v1.length)) yield (v1(i)-v2(i)) }.toList
    val l = vecLength(dv)
    pow(E, (-gamma*l))
    }
  2. micrypt revised this gist Aug 3, 2011. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion radialBasis.scala
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    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 <- (1 to v1.length)) yield (v1(i)-v2(i)) }.toList
    val l = vecLength(dv)
    pow(scala.math.E, (-gamma*l))
    pow(E, (-gamma*l))
    }
  3. micrypt created this gist Aug 3, 2011.
    9 changes: 9 additions & 0 deletions radialBasis.scala
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    // 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 <- (1 to v1.length)) yield (v1(i)-v2(i)) }.toList
    val l = vecLength(dv)
    pow(scala.math.E, (-gamma*l))
    }