How can I generate a random value based on a custom probability density function?

조회 수: 14 (최근 30일)
MMA
MMA 2020년 6월 30일
편집: SC 2020년 6월 30일
I have a custom probability density function that describes the probability of a variable "d" which falls within a range of 1:300.
I would like do define a function that would generate a random variable based on this custom pdf, similar to the function
rand
The code I have so far is
mu = 3.7;
sigma = 0.92;
d = 1:300;
PDF_dailydrivingdistance = ((1)./(d.*sigma.*sqrt(2*pi))).*(exp((-(log(d)-mu).^2)./(2*sigma^2)));
% need to randomly generate d based off of 'PDF_dailydrivingdistance'

답변 (1개)

SC
SC 2020년 6월 30일
편집: SC 2020년 6월 30일

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by