Closed netpoetica closed 9 years ago
The culprit is https://github.com/brycebaril/node-stats-lite/blob/master/stats.js#L74
Shouldn't this function just return an array of modes if there are multiple modes?
I have no idea how I didn't see this until today :blush:
When I wrote this I sided toward the solution that if the dataset has multiple modes it has no mode.
This provided a few things for me:
mode(dataset) =~ dataset
However, I'm pretty ok with switching the behavior of this now. I have some small concerns about allowing multiple return types and V8 optimizations, but I don't know how often mode
is being used in people's hot loops.
As for changing the return type, most likely people were having to look for NaN
as is, so looking for an Array is not really a significant code change.
Pushed as v2.0.0
mode
now returns an ES6 Set of the modes for multi-modal datasets
Looking into it now but I figured I should report asap, will let you know if I figure it out
Node v0.10.21, Mac OSX