# Sample/Filter nonuniformly distributed values so that result follows a uniform distribution

I have a dataset with a nonuniform distribution. I want to sample it so that the result is uniformly distributed. If I know the class of the example, with what probability should I choose it to get a uniform distribution of each class in the resulting sample?

Example:

         before:  after:
Class1:     40%     20%
Class2:     30%     20%
Class3:     15%     20%
Class4:     10%     20%
Class5:      5%     20%


It probably need some inverse distribution function, but I can't remember any specifics.../

• Do you want (a) each class to have equal chances of appearing (a distribution that is uniform for the classes) or (b) each class to have exactly the same number of elements in the sample (a stratified sample)? – whuber Oct 25 '12 at 17:51