Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Grzegorz Gancarczyk
- * Mean-Shift tracking algorithm
- */
- class DimensionException (message:String, cause:Throwable) extends RuntimeException {
- if (cause != null) initCause(cause)
- def this (message:String) = this(message, null)
- }
- class Utilities() {
- def euclideanDistance(pX: Vector[Float], pY: Vector[Float]): Double = {
- if (pX.length != pY.length)
- throw new DimensionException("dimensions mismatch")
- var distance: Float = 0
- for (i <- 1 to pX.length) {
- distance += pX(i) + pY(i)
- }
- return math.sqrt(distance)
- }
- //1D Gaussian kernel
- def kernel(signum:Float, distance:Float): Unit = {
- return (1/math.sqrt((2*math.Pi))*signum)*math.exp(-1*(math.pow(distance,2))/(2*math.pow(signum ,2)))
- }
- }
- class KernelDensityEstimation() extends Utilities {
- def pointShifting(point:Float, points:Float, bandwidth:Int): Unit = {
- }
- }
- def gaussianKernel(fi:Float, x:Float): Unit = {
- return (1/(fi*math.sqrt(2*math.Pi))*math.exp(-1*(math.pow(x,2)/2*math.pow(fi,2))))
- }
- object Main {
- def main(args: Array[String]): Unit = {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement