title: Minkowski distance code
body: <p>I have the java code below which i used to calculate the Minkowski distance, </p>
  
  <pre><code> class Minkowski {
   public static void main( String  [] arg){
      int p=2;
      double [] Mski = new double[5];
  
      double  [] a = { 1, 2, 3, 4,5};
      double  [] b = { 6,7,8,9,11};
     System.out.println(Arrays.toString(Minkowski1(a,b,p);
   }
  public static double Minkowski1( double [] a , double [] b, int q)  
  { 
      double sum = 0;
      for(int f = 0; f &lt; a.length; f++){
          sum += Math.pow( Math.abs(a[f] - b[f]),q );
      }
      return Math.pow(sum, 1.0 / q);
   }
  </code></pre>
  
  <p>The Code produce different result from a Minkowski distance matlab code  :</p>
  
  <pre><code>for i=1 : 5
      result2(i)=sum(abs(X(i)-Y(i)).^p).^(1/p)
  end
  the result in matlab is 5 5 5 5 6,and java one is not same 
  </code></pre>
  
  <p>any suggestion please </p>