I have an array containing many values between 0 and 360 (like degrees in a circle), but unevenly distributed:
1,45,46,47,48,49,50,51,52,53,54,55,100,120,140,188, 210, 280, 355
Now I need to reduce those values to e.g. 4 only, but as evenly as possible distributed values.
How to do that?
Thanks, Jan
Use a clustering algorithm to divide your data into evenly distributed partitions. Then grab a random value from each cluster. The following
$datafile
looks like this:First column is a tag, second column is data. Running the following with
$K = 4
:returns this:
First column is the center of the cluster, second is the selected value from that cluster. The centers' distance to one another should be maximized according to the Expectation Maximization algorithm.