samedi 14 janvier 2017

Generating random numbers from arbitrary probability density function

I would like to be able to generate random numbers with a probability density function that comes from a drawn curve. These two below have the same area under the curve but should produce lists of random numbers with different characteristics.

enter image description here

My intuition is that one way would be to do it is to sample the curve, and then use the areas of those rectangles to feed an np.random.choice to pick a range to do an ordinary random in the range of that rectangle's range.

enter image description here

This doesn't feel like a very efficient way to do it. Is there a more 'correct' way to do it?

Aucun commentaire:

Enregistrer un commentaire