## Problem of the Week 1115## Randy the Distracted ResearcherRandy the Researcher is a good graduate student, so he likes his graphs. He would like to graph the relationship between IQ and weight for 9 Chihuahuas with surgically enhanced brains. Randy decides to use a bar chart with three bars. Each bar will display the mean IQ corresponding to the lightest, middle, and heaviest dogs respectively. If the individual dog weights are unique, the natural binning is obvious. For example, given weights (in lbs) 10, 12, 30, 27, 13, 18, 15, 16, and 17 the natural binning would be:
When multiple Chihuahuas have equal weights, things get trickier. If the dogs have weight 10, 12, 16, 17, 18, 16, 22, 16, and 16, Randy believes the most even binning is:
Randy finds this to be an interesting problem -- much more interesting than designing uber-smart canines. He decides that the appropriate measure of the "evenness" of a binning is entropy, which is For example, the entropy for the second set of bins (with four 16 lb'ers) would be:
Provide an algorithm to solve the general version of Randy's problem: given d dogs and b bins, calculate the assignment of dogs to bins that yields maximum entropy. Your binning must have the following properties: -
Each dog in bin i > 1 must have weight strictly less than each dog in bin
i + 1. - (A corollary of 1) All dogs with equal weight must be in the same bin.
You can assume that there are more distinct dog weights than bins. An O(m*n © Copyright 2009 Dave Ehren and Shilad Sen. Reproduced with permission. |

25 February 2009