Generate a random number with specific probability density function

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

답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 4월 7일

0 개 추천

slicesample will do this for you.

댓글 수: 2

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.
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2015년 4월 7일

댓글:

2015년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by