mercredi 4 janvier 2017

python: random sampling from self-defined probablity function

I have a piecewise quadratic distribution with a probability function:

p(x)= c(x/a)^2 if 0≤x<a; 
      c((b+a-x)^2/b)^2 if a≤x≤b;
      0 otherwise

Suppose c, a, b are known, I am trying to draw 100 random samples from the distribution. How can I do it with numpy/scipy? Thanks!




Aucun commentaire:

Enregistrer un commentaire