commons-issues mailing list archives

Site index · List index
Message view
Top
From "Phil Steitz (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (MATH-582) Percentile does not work as described in API
Date Sat, 11 Jun 2011 22:31:58 GMT
```
[ https://issues.apache.org/jira/browse/MATH-582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Phil Steitz resolved MATH-582.
------------------------------

Resolution: Fixed

Patch applied (with test) in trunk in r1134802.

Thanks, Andre for the report and thanks, Christopher for the patch!

> Percentile does not work as described in API
> --------------------------------------------
>
>                 Key: MATH-582
>                 URL: https://issues.apache.org/jira/browse/MATH-582
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Andre Herbst
>         Attachments: MATH-582.patch
>
>
> example call:
> StatUtils.percentile(new double[]{0d, 1d}, 25)   returns 0.0
> The API says that there is a position being computed:  p*(n+1)/100 -> we have p=25
and n=2
> I would expect position 0.75 as result. Next step according to the API is: interpolation
between both values at floor(0.25) and at ceil(0.25). Those values are 0d and 1d ... so lower
+ d * (upper - lower) should give 0d + 0.25*(1d - 0d) = 0.25
> But the above call returns 0 as result. This does not make sense to me.
> another example where I think the result is not correct:
> StatUtils.percentile(new double[]{0d, 1d, 1d, 1d}, 25)   returns 0.25
> we have pos = 25*5/100 = 1.25  ... so d = 0.25
> values at position floor(1.25) and ceil(1.25) are 1d and 1d. How comes that the result
is not between 1d?

--
This message is automatically generated by JIRA.