I've tried different algorithms and implementations, and numbers are
always off. I am trying to calculate standard deviation, here is my
code -
https://gist.github.com/1885591 . There is a similar
implementation -
https://gist.github.com/1211724 , which has the same
problem.
Now, if I change (from
https://gist.github.com/1885591):
> db.stats.mapReduce(map, reduce, { out: "video_stats"});
to:
> db.stats.mapReduce(map, reduce, { out: {replace : "video_stats"}, query: {"user":"abc"} });
Also, when I add min and max calculations, which are straight forward
(
https://gist.github.com/1211724 has them, and are also wrong), the
numbers are way off (much much higher).
What is going on? I'm on MongoDB 2.0.2.