How do I sample a random value from a normal distribution

조회 수: 6 (최근 30일)
Gumps
Gumps 2019년 4월 17일
댓글: Walter Roberson 2019년 4월 18일
I want to sample a value from a normal distribution and I wrote down this codes. Can someone please look at it and hint me if it is appropriate. I am Matlab basic user.
r=rand;
ci_l=find(cumu<=r,1,'last');
ci_h=find(cumu>=r,1,'first');
if abs(cumu(ci_l)-r)<=abs(cumu(ci_h)-r)
ci=ci_l;
else
ci=ci_h;
end
cmuO=getCDF(pdfY);
cmuO=cmuO/max(cmuO);
[~,idx]=min(abs(cmuO-cumu(ci)));
newVal=pdfX(idx);
  댓글 수: 7
Gumps
Gumps 2019년 4월 17일
Cumu was created somewhat with code related with makedist().
YES
Walter Roberson
Walter Roberson 2019년 4월 18일
Is the "YES" intended to mean that Yes, it is a vector sorted in increasing order?

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

답변 (1개)

James Tursa
James Tursa 2019년 4월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by