Code in Userguide for Statistics wrong or deprecated 
-----------------------------------------------------

                 Key: MATH-568
                 URL: https://issues.apache.org/jira/browse/MATH-568
             Project: Commons Math
          Issue Type: Improvement
    Affects Versions: 2.2
         Environment: windows 7
            Reporter: Christoph M. Friedrich
            Priority: Trivial


The code for the Statistics examples is not running and can easily be fixed. 
Example:
// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();

// Add the data from the array
for( int i = 0; i < inputArray.length; i++) {
        stats.addValue(inputArray[i]);
}

// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double median = stats.getMedian();

Fails with getMedian not found, change to getPercentile(50);

The second Codeexample for StatuUtils states:
// Compute statistics directly from the array
// assume values is a double[] array
double mean = StatUtils.mean(values);
double std = StatUtils.variance(values);
double median = StatUtils.percentile(50);

the last line needs to be changed to: double median = 
StatUtils.percentile(values,50);



--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to