Uniform distribution help need.
Afficher commentaires plus anciens
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 commentaires
bym
le 25 Juin 2011
please format your code using the *{}Code* button
Andrew Newell
le 25 Juin 2011
See http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question.
Réponses (1)
Andrew Newell
le 25 Juin 2011
Hint: try
hist(x)
Catégories
En savoir plus sur Uniform Distribution (Continuous) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!