Uniform distribution help need.
이전 댓글 표시
Write a MATLAB script to do the following a. Create 10000 random variables uniformly distributed between 2 and 4. b. Create a histogram to approximate the actual probability density function. c. Superimpose the actual probability density function to the above histogram.
This is what i have done but have problem with creating the density function.
n=10000; x=2*rand[1,n]+2*ones[1,n]; plot(x) xlabel('index');ylabel('Amplitude');grid pause [m,z]=hist(x); w=max(z)/10; mm=m/(10000*w); v=linspace(min(x),max(x)); y=(1/Max(x)-Min(x))*ones(size(v)); bar(z,mm) hold on plot (v,y) xlabel('randon Variable Value'); ylabel('Probability Density') hold off
댓글 수: 2
bym
2011년 6월 25일
please format your code using the *{}Code* button
Andrew Newell
2011년 6월 25일
See http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question.
답변 (1개)
Andrew Newell
2011년 6월 25일
Hint: try
hist(x)
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!