Example usage for org.apache.commons.lang.math FloatRange getMaximumDouble

List of usage examples for org.apache.commons.lang.math FloatRange getMaximumDouble

Introduction

In this page you can find the example usage for org.apache.commons.lang.math FloatRange getMaximumDouble.

Prototype

public double getMaximumDouble() 

Source Link

Document

Gets the maximum number in this range as a double.

Usage

From source file:au.org.ala.delta.intkey.model.ReportUtils.java

/**
 * Generates summary information for the supplied real character and list of
 * taxa//  ww  w  . j  a va2 s  .  com
 * 
 * @param ch
 *            The character
 * @param attrs
 *            All attributes for the character
 * @param taxa
 *            The taxa
 * @param outputToDeltaFormat
 *            True if the summary is being output to delta format. The
 *            output is slightly different in this situation.
 * @return A list of objects:
 *         <ol>
 *         <li>The number of unknown attributes for the supplied character
 *         and taxa (int)</li>
 *         <li>The number of inapplicable attributes for the supplied
 *         character and taxa (int)</li>
 *         <li>The number of inapplicable attributes for the supplied
 *         character and taxa (int)</li>
 *         <li>The number of recorded attributes for the supplied character
 *         and taxa (int)</li>
 *         <li>Minimum value for the attributes for the supplied character
 *         and taxa (Double)</li>
 *         <li>Maximum value for the attributes for the supplied character
 *         and taxa (Double)</li>
 *         <li>The number of the taxon whose attribute for the supplied
 *         character has the minimum value (int)</li>
 *         <li>The number of the taxon whose attribute for the supplied
 *         character has the maximum value (int)</li>
 *         <li>Mean of the values for the attributes for the supplied
 *         character and taxa (Double)</li>
 *         <li>Standard deviation of the values for the attributes for the
 *         supplied character and taxa (Double)</li>
 *         </ol>
 */
public static List<Object> generateRealSummaryInformation(RealCharacter ch, List<Attribute> attrs,
        List<Item> taxa, boolean outputToDeltaFormat) {
    int numUnknown = 0;
    int numInapplicable = 0;
    int numRecorded = 0;

    double minValue = Double.MAX_VALUE;
    double maxValue = Double.MIN_VALUE;
    int minValueTaxonIndex = 0;
    int maxValueTaxonIndex = 0;

    // Collect data points to use to calculate mean and standard deviation
    List<Double> valuesForMeanAndStdDev = new ArrayList<Double>();

    for (Item taxon : taxa) {
        RealAttribute attr = (RealAttribute) attrs.get(taxon.getItemNumber() - 1);
        if (attr.isUnknown() && !attr.isInapplicable()) {
            numUnknown++;
            continue;
        } else if (attr.isInapplicable()) {
            if (outputToDeltaFormat && attr.getCharacter().getControllingCharacters().isEmpty()) {
                numInapplicable++;
            } else if (!outputToDeltaFormat && attr.isUnknown()) {
                numInapplicable++;
            }

            if (attr.isUnknown()) {
                continue;
            }
        }

        numRecorded++;

        FloatRange presentRange = attr.getPresentRange();

        if (presentRange.getMinimumDouble() < minValue) {
            minValue = presentRange.getMinimumDouble();
            minValueTaxonIndex = taxon.getItemNumber();
        }

        if (presentRange.getMaximumDouble() > maxValue) {
            maxValue = presentRange.getMaximumDouble();
            maxValueTaxonIndex = taxon.getItemNumber();
        }

        // for calculating the mean and standard deviation, use the average
        // the two numbers that
        // specify the range.
        valuesForMeanAndStdDev.add((presentRange.getMinimumDouble() + presentRange.getMaximumDouble()) / 2);
    }

    Pair<Double, Double> pairMeanStdDev = calcuateMeanAndStandardDeviation(valuesForMeanAndStdDev);
    double mean = pairMeanStdDev.getFirst();
    double stdDev = pairMeanStdDev.getSecond();

    return Arrays.asList(new Object[] { numUnknown, numInapplicable, numRecorded, minValue, maxValue,
            minValueTaxonIndex, maxValueTaxonIndex, mean, stdDev });
}

From source file:au.org.ala.delta.intkey.directives.invocation.SummaryDirectiveInvocation.java

private List<Object> generateRealSummaryInformation(RealCharacter ch, List<Attribute> attrs) {
    int numUnknown = 0;
    int numInapplicable = 0;
    int numRecorded = 0;

    double minValue = Double.MAX_VALUE;
    double maxValue = Double.MIN_VALUE;
    int minValueTaxonIndex = 0;
    int maxValueTaxonIndex = 0;

    // Collect data points to use to calculate mean and standard deviation
    List<Double> valuesForMeanAndStdDev = new ArrayList<Double>();

    for (Item taxon : _taxa) {
        RealAttribute attr = (RealAttribute) attrs.get(taxon.getItemNumber() - 1);
        if (attr.isUnknown() && !attr.isInapplicable()) {
            numUnknown++;/* ww w  .  j av a2  s .co  m*/
            continue;
        } else if (attr.isUnknown() && attr.isInapplicable()) {
            numInapplicable++;
            continue;
        } else {
            numRecorded++;
        }

        FloatRange presentRange = attr.getPresentRange();

        if (presentRange.getMinimumDouble() < minValue) {
            minValue = presentRange.getMinimumDouble();
            minValueTaxonIndex = taxon.getItemNumber();
        }

        if (presentRange.getMaximumDouble() > maxValue) {
            maxValue = presentRange.getMaximumDouble();
            maxValueTaxonIndex = taxon.getItemNumber();
        }

        // for calculating the mean and standard deviation, use the average
        // the two numbers that
        // specify the range.
        valuesForMeanAndStdDev.add((presentRange.getMinimumDouble() + presentRange.getMaximumDouble()) / 2);
    }

    Pair<Double, Double> pairMeanStdDev = calcuateMeanAndStandardDeviation(valuesForMeanAndStdDev);
    double mean = pairMeanStdDev.getFirst();
    double stdDev = pairMeanStdDev.getSecond();

    return Arrays.asList(new Object[] { numUnknown, numInapplicable, numRecorded, minValue, maxValue,
            minValueTaxonIndex, maxValueTaxonIndex, mean, stdDev });
}