Is there a general way to join SciPy (or NumPy) probability distributions to create a mixture probability distribution which can then be sampled from?
I have such a distribution for display using something like:
mixture_gaussian = (norm.pdf(x_axis, -3, 1) + norm.pdf(x_axis, 3, 1)) / 2
which if then plotted looks like:
However, I can't sample from this generated model, as it's just a list of points which will plot as the curve.
Note, this specific distribution is just a simple example. I'd like to be able to generate several kinds of distributions (including "sub"-distributions which are not just normal distributions). Ideally, I would hope there would be someway for the function to be automatically normalized (i.e. not having to do the / 2
explicitly as in the code above.
Does SciPy/NumPy provide some way of easily accomplishing this?
This answer provides a way that such a sampling from a multiple distributions could be done, but it certainly requires a bit of handcrafting for a given mixture distribution, especially when wanting to weight different "sub"-distributions differently. This is usable, but I would hope for method that's a bit cleaner and straight forward if possible. Thanks!