How can I make a custom random number distribution?

조회 수: 23 (최근 30일)
Taneli Hautaniemi
Taneli Hautaniemi 2017년 7월 13일
답변: Ka Mirul 2017년 11월 14일
Hi! How can I use the inverse transform sampling in MATLAB to set the distributions of my random numbers? I know that normally distributed randn is just rand with a Gaussian distribution, so the latter should somehow be replaced with a custom pdf to generate a new function randc to be used in similar manner than the others. I thank for your help in advance!
  댓글 수: 1
James Tursa
James Tursa 2017년 7월 13일
What is your custom pdf based on? A formula description? A set of data points that you want to fit a pdf to? Or ...?

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

답변 (3개)

Image Analyst
Image Analyst 2017년 7월 13일
You can do your own if you know the function and can get the CDF of the probability density function. You can then use inverse transform sampling. See Wikipedia: http://en.wikipedia.org/wiki/Inverse_transform_sampling
I attach an example for the Rayleigh distribution. Adapt as needed, for example to use an ad hoc, discrete distribution rather than an analytical one with a formula.

Star Strider
Star Strider 2017년 7월 13일
In the Statistics and Machine Learning Toolbox, you can generate random numbers from any of the supported Continuous Distributions (link) or discrete or multivariate distributions (listed in the Contents panel on the left of the page).
  댓글 수: 1
Taneli Hautaniemi
Taneli Hautaniemi 2017년 7월 13일
Thank you but isn't what I'm looking for. I want to use my own distribution with my own function.

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


Ka Mirul
Ka Mirul 2017년 11월 14일
I have create a video about generating random number in MATLAB
https://www.youtube.com/watch?v=MyH3-ONYL_k
Hope that will help you

Community Treasure Hunt

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

Start Hunting!

Translated by