[ 
https://issues.apache.org/jira/browse/STATISTICS-90?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17937409#comment-17937409
 ] 

Alex Herbert commented on STATISTICS-90:
----------------------------------------

I have added the range functions to the master branch:

Descriptive statistic instances are created using {{{}ofRange{}}}.

The median and quantile use {{{}evaluateRange{}}}.

E.g.
{code:java}
int[] values = {1, 1, 2, 3, 5, 8, 13, 21};

IntMax max = IntMax.ofRange(values, 3, 6);   // max=8

double median = Median.withDefaults().evaluateRange(values, 3, 6);   // 
median=5.0
{code}
Note: Overload of the {{evaluate}} method for the quantile with range arguments 
can lead to a potential user error due to the use of varargs for the 
probabilities:
{code:java}
// Existing
public double[] evaluate(int[] values, double... p);

// Overloaded
public double[] evaluate(int[] values, int from, int to, double... p);

// Should this be a range, or the quantiles [0.0, 1.0, 0.5]?
double[] x = ...
Quantile.withDefaults().evaluate(x, 0, 1, 0.5)
{code}
In this case it is a more consistent API to include Range in the method name.

> Support statistic creation using an array range
> -----------------------------------------------
>
>                 Key: STATISTICS-90
>                 URL: https://issues.apache.org/jira/browse/STATISTICS-90
>             Project: Commons Statistics
>          Issue Type: New Feature
>          Components: descriptive
>    Affects Versions: 1.1
>            Reporter: Alex Herbert
>            Priority: Minor
>
> Add support for using part of an array to create statistics:
> {code:java}
> double[] x = ...
> int from = ...
> int to = ...
> Min.ofRange(x, from, to);
> DoubleStatistics.ofRange(EnumSet.of(Statistic.MIN), x, from, to);{code}
> This change should have no impact on performance for full length arrays and 
> improve memory consumption by avoiding array copies on sub-ranges. Results 
> from STATISTICS-89 indicate a non-negligible performance gain for fast 
> computing statistics.
> Note: Support for sub-ranges is present in the Commons Math 
> UnivariateStatistic interface. This change will allow supporting replacement 
> of the Math API with Statistics.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to