Mercurial > hg > jslab
comparison src/samer/mds/Minkowski.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 package samer.mds; | |
2 import samer.core.types.*; | |
3 import samer.maths.*; | |
4 | |
5 /** Minkowski metric */ | |
6 | |
7 public class Minkowski implements MDS.Metric { | |
8 VDouble exponent=new VDouble("exponent",1); | |
9 public Minkowski(double p) { exponent.set(p); } | |
10 public double d(double [] x, double [] y, double [] r) { | |
11 Mathx.sub(r,y,x); | |
12 double q=0, p=exponent.value; | |
13 for (int i=0; i<r.length; i++) q+=Math.pow(r[i],p); | |
14 return Math.pow(q,1/p); | |
15 } | |
16 } |