commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Disc Magnet <discmag...@gmail.com>
Subject [math] Can't find newInstance() and getMedian() methods in DescriptiveStatistics
Date Sat, 20 Mar 2010 21:50:44 GMT
I was trying to run the first example given in this page:
http://commons.apache.org/math/userguide/stat.html My program is as
follows:

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;

public class DescStats
{
    public static void main(String[] args)
    {
        System.out.println("hello, world");

        DescriptiveStatistics stats = DescriptiveStatistics.newInstance();

        int inputArray[] = new int[] {5, 7, 1, 3, 8};
        for (int i = 0; i < inputArray.length; i++) {
            stats.addValue(inputArray[i]);
        }

        double mean = stats.getMean();
        double std = stats.getStandardDeviation();
        double median = stats.getMedian();

        System.out.println("mean: " + mean);
        System.out.println("std: " + std);
        System.out.println("median: " + median);
    }
}

I get this error on trying to compile:

DescStats.java:9: cannot find symbol
symbol  : method newInstance()
location: class org.apache.commons.math.stat.descriptive.DescriptiveStatistics
        DescriptiveStatistics stats = DescriptiveStatistics.newInstance();
                                                           ^
DescStats.java:18: cannot find symbol
symbol  : method getMedian()
location: class org.apache.commons.math.stat.descriptive.DescriptiveStatistics
        double median = stats.getMedian();

I checked the apidocs at
http://commons.apache.org/math/apidocs/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.html
and found that newInstance() and getMedian() methods are not present.
Is the tutorial very old and out of sync with the latest Commons Math?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message