Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.11 KB | None | 0 0
  1. /**
  2.   * Created by Grzegorz Gancarczyk
  3.   * Mean-Shift tracking algorithm
  4.   */
  5.  
  6.  
  7. class DimensionException  (message:String, cause:Throwable) extends RuntimeException {
  8.   if (cause != null) initCause(cause)
  9.   def this (message:String) = this(message, null)
  10. }
  11.  
  12. class Utilities() {
  13.   def euclideanDistance(pX: Vector[Float], pY: Vector[Float]): Double = {
  14.     if (pX.length != pY.length)
  15.       throw new DimensionException("dimensions mismatch")
  16.     var distance: Float = 0
  17.     for (i <- 1 to pX.length) {
  18.       distance += pX(i) + pY(i)
  19.     }
  20.     return math.sqrt(distance)
  21.   }
  22.  
  23.   //1D Gaussian kernel
  24.   def kernel(signum:Float, distance:Float): Unit = {
  25.     return (1/math.sqrt((2*math.Pi))*signum)*math.exp(-1*(math.pow(distance,2))/(2*math.pow(signum ,2)))
  26.   }
  27. }
  28. class KernelDensityEstimation() extends Utilities {
  29.   def pointShifting(point:Float, points:Float, bandwidth:Int): Unit = {
  30.  
  31.  
  32.  
  33.   }
  34. }
  35. def gaussianKernel(fi:Float, x:Float): Unit = {
  36.   return (1/(fi*math.sqrt(2*math.Pi))*math.exp(-1*(math.pow(x,2)/2*math.pow(fi,2))))
  37. }
  38.  
  39. object Main {
  40.   def main(args: Array[String]): Unit = {
  41.  
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement