dimanche 14 novembre 2021

How to generate random numbers according to a custom probability density function (Python)?

I have a list containing random variables X and the fractions they occur; so if I plot these I get a probability density function. I am wondering how I can then use this probability density function to generate some random numbers?

I've used scipy.interpolate.CubicSpline to obtain a Python function for this data. How do I use this function to generate random numbers?




Aucun commentaire:

Enregistrer un commentaire