Java Median median(double... a)

Here you can find the source of median(double... a)

Description

median

License

Open Source License

Declaration

public static double median(double... a) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://  w  ww  .ja  v a  2  s.  com
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

import java.util.Arrays;

public class Main {
    public static double median(double... a) {
        if (a == null) {
            return 0;
        }
        int count = a.length;
        double[] b = new double[a.length];
        System.arraycopy(a, 0, b, 0, count);
        Arrays.sort(b);
        if (count > 0) {
            return b[count / 2];
        } else {
            return 0;
        }
    }
}

Related

  1. getMedian(int[] array)
  2. getMedianValue(ArrayList values)
  3. median(ArrayList v)
  4. median(ArrayList values)
  5. Median(ArrayList values)
  6. median(double[] a)
  7. median(double[] a)
  8. median(double[] arr)
  9. median(double[] array)