Generate a random number with specific probability density function

5 visualizaciones (últimos 30 días)
ricard molins
ricard molins el 7 de Abr. de 2015
Comentada: Torsten el 8 de Abr. de 2015
I'm trying to generate a random number with a given PDF. I have the PDF stored as :
  • X: with the possible values
  • Y: with the density
plot(X,Y) displays the PDF
I've tried to use fitdist and makedist but I'm not able to convert it into a PDF object or anything usable.
Thanks you in advance

Respuestas (1)

Sean de Wolski
Sean de Wolski el 7 de Abr. de 2015
slicesample will do this for you.
  2 comentarios
ricard molins
ricard molins el 8 de Abr. de 2015
It may be that I'm pretty new to Matlab but I'm not able to figure out how to use slicesample with the data I have. As I can see slicesample needs a function from the pdf and I have the "sampled" pdf not a function that defines it.
Torsten
Torsten el 8 de Abr. de 2015
Given x, interpolate the density y(x) from your data vector Y.
This will give you a Kind of "function" y(x).
Best wishes
Torsten.

Iniciar sesión para comentar.

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by