Statistical Calculations
Hi,
I am fetching very large data sets out of a database.
The values that I am fetching are doubles.
I am wanting to know what sort of array would be most suitable for speed and memory consumption for iterating through to do calculations like mean, max, median, mode, min, std dev etc.
Currently I am using ArrayList - can anyone tell me if this is suitable or if I can gain any extra performance by using something else like hash maps?
Thanks
> I am wanting to know what sort of array would be most
There is only one sort of array.
> suitable for speed and memory consumption for
> iterating through to do calculations like mean, max,
> median, mode, min, std dev etc.
>
> Currently I am using ArrayList - can anyone tell me
Which isn't an array but an array-backed List.
> if this is suitable or if I can gain any extra
> performance by using something else like hash maps?
Performance for just iterating over the whole thing? No. Won't be faster than an ArrayList, except for maybe a normal array since you avoid one method call.
Actually, if you have a double[], it should surely be preferred to an ArrayList<Double>, because you can avoid autoboxing that way.
> ... to do calculations like mean, max,> median, mode, min, std dev etc. ...You can do it yourself, or use some existing API, like this one: http://jakarta.apache.org/commons/math/