Retrive the quartile value from an array : Array Compare « Collections Data Structure « Java

Retrive the quartile value from an array

import java.util.Arrays;

 * <p>Static methods for doing useful math</p><hr>
 * @author  : $Author: brian $
 * @version : $Revision: 1.1 $
 * <hr><p><font size="-1" color="#336699"><a href="">
 * The Monterey Bay Aquarium Research Institute (MBARI)</a> provides this
 * documentation and code &quot;as is&quot;, with no warranty, express or
 * implied, of its quality or consistency. It is provided without support and
 * without obligation on the part of MBARI to assist in its use, correction,
 * modification, or enhancement. This information should not be published or
 * distributed to third parties without specific written permission from
 * MBARI.</font></p><br>
 * <font size="-1" color="#336699">Copyright 2002 MBARI.<br>
 * MBARI Proprietary Information. All rights reserved.</font><br><hr><br>

public class Util{
     * Retrive the quartile value from an array
     * .
     * @param values THe array of data
     * @param lowerPercent The percent cut off. For the lower quartile use 25,
     *      for the upper-quartile use 75
     * @return
    public static double quartile(double[] values, double lowerPercent) {

        if (values == null || values.length == 0) {
            throw new IllegalArgumentException("The data array either is null or does not contain any data.");

        // Rank order the values
        double[] v = new double[values.length];
        System.arraycopy(values, 0, v, 0, values.length);

        int n = (int) Math.round(v.length * lowerPercent / 100);
        return v[n];



Related examples in the same category

1.Check if a text is present at the current position in a buffer for byte array
2.Check if a text is present at the current position in a buffer(char array and char array)
3.Check if a text is present at the current position in a buffer(char array and string)
4.Returns true if all the references in array1 are equal to all the references in array2 (two null references are considered equal for this test).
5.Returns true if any two items in the array are equal to one another. Any null values in the array are ignored.
6.Tests two float arrays for equality.
7.Does the source array equal the match array
8.Does this byte array begin with match array content?
9.Compares the initial elements of two arrays.
10.String search and reflection helper methodsString search and reflection helper methods
11.Checks whether two arrays are the same length, treating null arrays as length 0.
12.Checks whether two arrays are the same type taking into account multi-dimensional arrays.
13.Get the maximum value in a double array
14.Compare equality of two two-dimensional boolean array
15.Two double value arrays are almost equal
16.Find the index of the array nearest to the value.
17.Reverses the contents of the array.