Java Median median(double[][] values)

Here you can find the source of median(double[][] values)

Description

median

License

Apache License

Declaration

public static double median(double[][] values) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double median(double[][] values) {
        double[] flatvalues = new double[values.length * values.length];
        for (int i = 0; i < values.length; i++) {
            for (int j = 0; j < values.length; j++) {
                flatvalues[i * values.length + j] = values[i][j];
            }/*from  w  ww. j  ava2  s  .c om*/
        }
        if (flatvalues.length % 2 == 0)
            return flatvalues[flatvalues.length / 2];
        int lowerindex = flatvalues.length / 2;
        int upperindex = flatvalues.length / 2 + 1;
        return (flatvalues[lowerindex] + flatvalues[upperindex]) / 2;
    }
}

Related

  1. median(double[] vals)
  2. median(double[] values)
  3. median(double[] x)
  4. median(double[] x)
  5. median(double[] x)
  6. median(final ArrayList values)
  7. median(final double... in)
  8. median(final double... values)
  9. median(final double[] values)