Closed christianp closed 10 months ago
@JanOnBread here's an issue describing how I want the bin functions to work.
can I take this issue?
And also can you please specify where we need to add that function and in which language you want
@yashmonk123 thanks for offering to help, but @janonbread took this on. I forgot to assign this issue to her - sorry for the inconvenience!
Data binning is the process of grouping data into a fixed number of smaller bins.
There should be functions to do this with lists of numbers in JME. There are a few ways to do it, depending on how much information you can give in advance, and how much you infer from the data.
So we need to define a few versions of
bin
that take different arguments. I'm not sure exactly what their names should be.Here are some example inputs and outputs:
For the function
bin(values, bin_width)
:values:
[1,2,3,4]
bin_width:2
Returns:[ [1,2], [3,4] ]
values:
[10,11,12,13]
bin_width:2
Returns:[ [10,11], [12,13] ]
values:
[13,12,11,10]
bin_width:2
Returns:[ [10,11], [12,13] ]
values:
[1, 8]
bin_width:3
Returns:[ [1], [], [8] ]
values:
[0,2,2,3,6,10,11,13]
bin_width:3
Returns:[ [0,2,2], [3], [6], [10,11], [13] ]
values:
[1.36, 1.45, 1.60, 1.23, 1.25, 1.66, 1.10]
bin_width:0.1
Returns:[ [1.1], [1.23, 1.25], [1.36], [1.45], [], [1.60, 1.66] ]
For the function
bin(values, num_bins)
: bin_width = (max(values) - min(values))/num_binsvalues:
[1,2,3,4]
num_bins:2
Returns:[ [1,2], [3,4] ]
values:
[10,11,12,13]
num_bins:2
Returns:[ [10,11], [12,13] ]
values:
[10,11,12,13]
num_bins:3
Returns:[ [10], [11], [12,13] ]
values:
[13,12,11,10]
num_bins:3
Returns:[ [10], [11], [12,13] ]
values:
[1, 8]
num_bins:2
Returns:[ [1], [8] ]
values:
[0,2,2,3,6,10,11,13]
num_bins:5
Returns:[ [0,2,2], [3], [6], [10], [11,13] ]
values:
[1.36, 1.45, 1.60, 1.23, 1.25, 1.66, 1.10]
num_bins:4
Returns:[ [1.10, 1.23], [1.25, 1.36], [1.45], [1.60, 1.66] ]
For the function
bin(values, start, end, num_bins)
: bin_width = (end - start)/num_binsvalues:
[1,2,3,4]
start:0
end:5
num_bins:2
Returns:[ [1,2], [3,4] ]
values:
[10,11,12,13]
start:10
end:15
num_bins:2
Returns:[ [10,11], [12,13] ]
values:
[10,11,12,13]
start:0
end:15
num_bins:3
Returns:[ [], [], [10, 11, 12,13] ]
values:
[0,2,2,3,6,10,11,13]
start:0
end:15
num_bins:5
Returns:[ [0,2,2], [3], [6], [10,11], [13] ]
values:
[1.36, 1.45, 1.60, 1.23, 1.25, 1.66, 1.10]
start:1
end:2
num_bins:10
Returns:[ [], [1.10], [1.23,1.25], [1.36], [1.45], [], [1.60, 1.66], [], [], [] ]