0

I want to find the smallest set that represents a distribution of items. Say I have the following items with distributions:

A: 25%
B: 25%
C: 50%

The smallest set that accurately represents this distribution is the following:

[A,B,C,C]

That's easy to do without thinking too hard about it with this small example, but honestly I don't know how I got from input to that set, logically. If I knew the rules to get from those distributions to that set, I could theoretically do that with a larger input (which is what I need to do).

Does anyone have any advice or could at least point me in the correct direction?

md2perpe
  • 26,770
  • Compute 100%/25% = 4 100%/25% = 4 100%/50% = 2. So compute lcm(4,4,2) = 4. 425% = 1. 425% = 1. 4*50% = 2. So one A, one B, and two C's – latbbltes May 15 '20 at 14:31

1 Answers1

1

Represent each of your percentages as a fraction, so $25\%=\frac 14$ in lowest terms. If at least one is not rational, you are sunk. The minimum set size is the least common multiple of the denominators. If all the numbers are whole numbers of percent, $100$ is guaranteed to work, but there may be a smaller number.

Ross Millikan
  • 374,822
  • This helped so much. I ended up coming up with a solution to my problem written in Go using this answer as a starting point - https://play.golang.org/p/JCEWCgWiemG (quick and dirty, going to clean it up before moving it into my actual project) – George Edward Shaw IV May 15 '20 at 15:22