You can use the cumulative density function to generate random numbers from an arbitrary distribution, as described here .
Using a histogram to create a smooth cumulative density function is not trivial; you can use interpolation, for example scipy.interpolate.interp1d () for values between the centers of your boxes, and this will work fine for a histogram with a sufficiently large number of boxes and items. However, you need to determine the shape of the tails of the probability function, that is, for values smaller than the smallest bit, or greater than the largest bit. You can provide your Gaussian houses based, for example, on binding a Gaussian to your histogram) or any other tail shape that matches your problem, or just truncate the distribution.
Example:
import numpy import scipy.interpolate import random import matplotlib.pyplot as pyplot
This does not process the tails and better processes the edges of the bin, but you can start using the histogram to generate more values with the same distribution.
PS You can also try to match a certain known distribution described by several values (which, I think, is what you mentioned in the question), but the above non-parametric approach is more universal.
Alex I
source share