How do I superimpose a pdf over a histogram?
이전 댓글 표시
i want to superimpose the pdf to the histogram. i have written those codes. this is the actual question.
Create 10,000 uniform (0, 1) random variables. · Create 10.000 exponentially distributed random variables by applying the inverse function of F (x) X to the above uniform random variables. · Plot the histogram of the exponentially distributed random variables to approximate the actual pdf. · Superimpose the actual pdf to the above histogram.
this is my codes
[u=rand(1,10000);
lam=0.5;
x=-1/lam.*log(1-u);
y=linspace(min(x),max(x));
h=exp(-y/2);
hist(x),
hold on
plot(y,h)
답변 (2개)
Sean de Wolski
2011년 7월 5일
It's plotting both of them; it's just the pdf is on the range of 0-1 (y values) and the histogram is on the range of 0-7000. Normalize by the number of elements to get the histogram on the range of 0-1. Or use subplots and explain the merits of them v. superimposing to your professor.
axis([0 25 0 1])
and you'll see the pdf line.
카테고리
도움말 센터 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!