You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Disc Magnet <di...@gmail.com> on 2010/03/20 22:50:44 UTC

[math] Can't find newInstance() and getMedian() methods in DescriptiveStatistics

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


Re: [math] Can't find newInstance() and getMedian() methods in DescriptiveStatistics

Posted by Phil Steitz <ph...@gmail.com>.
Luc Maisonobe wrote:
> Disc Magnet a écrit :
>> 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?
> 
> This is a documentation bug. Factory features have been deprecated in
> 1.2 and removed in 2.0, but it seems we forgot to update this example in
> the stat part, despite this part has been updated several times since then.
> 
> Could you open a JIRA issue so we don't forget it ?
> 
> Thanks for reporting this.

Fixed in r925826.  Thanks!

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


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


Re: [math] Can't find newInstance() and getMedian() methods in DescriptiveStatistics

Posted by Luc Maisonobe <Lu...@free.fr>.
Disc Magnet a écrit :
> 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?

This is a documentation bug. Factory features have been deprecated in
1.2 and removed in 2.0, but it seems we forgot to update this example in
the stat part, despite this part has been updated several times since then.

Could you open a JIRA issue so we don't forget it ?

Thanks for reporting this.
Luc

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


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