Uniform distribution help need.
Show older comments
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 Comments
bym
on 25 Jun 2011
please format your code using the *{}Code* button
Andrew Newell
on 25 Jun 2011
See http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question.
Answers (1)
Andrew Newell
on 25 Jun 2011
Hint: try
hist(x)
Categories
Find more on Uniform Distribution (Continuous) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!