How to select a small amount of numbers such that a distribution matches another as closely as possible?

13 Views Asked by At

I have two sets of numbers (1000 in each set, integers), one of those distributions remains constant (reference), but the other changes slightly and some numbers are dropped. When a number is dropped, I need to replace it with another number such that the resulting distribution is as close to the original (reference) as possible.

I could loop over possible values (or combinations in cases where multiple numbers were dropped) and in each iteration perform a KS test and pick the best result, but I was wondering if there may be quicker, more intelligent, ways to go around this.

Thank you in advance!