-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide function for binning one-dimensional data #487
Comments
Hello @gvwilson. Just chiming in regarding point |
👍 thank you |
1 seems great, and as Guillaume points out, yep, we've got 3. 2: my main question is whether the binBoundaries function should operate on data, or on binned output. Like would the ideal API look like:
Or
My suspicion is that API 2 is closer to ideal, because folks will likely want both binned data and bin boundaries, and the binBoundaries method will in API 1 have to implement a lot of the same logic as the bin() function. |
Since we need boundaries in order to bin data, what about enriching the signature to
|
I'm a bit hesitant to go beyond the 3-argument range with JavaScript APIs: as silly as it sounds, JavaScript's lack of named function arguments makes positional arguments pretty sloppy at best: in situ, that call would look like |
Removing the last argument and always binning down would get this down to three, and I think the order is reasonably intuitive - good enough? |
👍 yep, sounds good! |
(FWIW I had hoped a function like this, or a more straightforward histogram function, was present here) |
The library has quantile functions, but unless I've missed it, there isn't a function to bin data into N equal-width buckets for creating histograms. (Yes, we can rely on plotting software to do this, but there are cases where having the empirical PDF is useful.) I propose:
bin(data: Array<number>, bins: number): Array<number>
returns an array of lengthbins
(integer > 0) with the count of values in each bin.binBoundaries(data: Array<number>, bins: number): Array<number>
returns an array of lengthbins+1
with the inter-bin boundary values.minmax
tomin
andmax
to calculate the minimum and maximum values in an array in a single pass.If this proposal is accepted, I volunteer to do the work.
The text was updated successfully, but these errors were encountered: