On 7/4/13 9:26 AM, sebb wrote:
> On 4 July 2013 16:46, William Speirs <wspe...@apache.org> wrote:
>> The Frequency[1] class is what you're looking for. You can find a basic
>> example of it in the user guide [2].
> Perhaps the docs should include "mode" as an example as well?
> Or maybe it should be added to the Frequency class? (and StatUtils)
>
> AFAICT the only way to get the mode is to scan all the entries looking
> for the the maximum count, caching the value(s) on the way.
> This is not completely trivial.

Right.  That is what Frequency does, essentially.  It would make
sense to add a method to Frequency returning a collection or
double[] (since mode is not well-defined - i.e., there can be
several equiprobable maxima of the pmf).  Then add a convenience
method (possibly multiple, for different input data types) to
StatUtils that uses this.

Might also make sense to add mode as a (single-valued) property of
IntegerDistribution.  Will be NaN sometimes, but same is true of
mean and variance.

Patches welcome!

Phil




>
>> Bill-
>>
>> [1]
>> http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/Frequency.html
>> [2]
>> http://commons.apache.org/proper/commons-math/userguide/stat.html#a1.3_Frequency_distributions
>>
>>
>> On Thu, Jul 4, 2013 at 11:29 AM, Matt Benson <gudnabr...@gmail.com> wrote:
>>
>>> I don't know about [math], but [lang] 3.x has mean, median and mode in
>>> ObjectUtils.
>>>
>>> Matt
>>> On Jul 4, 2013 10:25 AM, "Ben Titmarsh" <ben.titma...@hotmail.co.uk>
>>> wrote:
>>>
>>>> Hi,
>>>>
>>>> I am looking for a library that can provide the mode (
>>>> http://en.wikipedia.org/wiki/Mode_%28statistics%29) of a set numbers.
>>>> This is a simple arithmetic operation but I am unable to find a reference
>>>> to this in the documentation.  Can anyone point it out to me, if not
>>>> suggest why it is not supported?
>>>>
>>>> Thanks,
>>>> Ben.
>>>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to