How do I superimpose a pdf over a histogram?
Mostrar comentarios más antiguos
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)
Respuestas (2)
Sean de Wolski
el 5 de Jul. de 2011
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.
Oleg Komarov
el 6 de Jul. de 2011
0 votos
1 comentario
Deepan J
el 16 de Nov. de 2020
use 'Normalization', 'PDF'
Categorías
Más información sobre Histograms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!