different cdf plot produced by 2 different code
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I created 2 plots below using the same data but different code. Could anybody explain to me why the cdf plot (red line) in the top plot does not match the bottom plot.
The bottom plot is the correct plot (I think).
binneddata = histc(data,bin) ./ length(data);
[y2,x2] = ecdf(data);
plotyy(bin, binneddata, x2, y2, @(x,y)bar(x,y,1,'c'), 'stairs')
[y2,x2] = ecdf(data);
[y1,x1] = hist(data);
plotyy(x1,y1,x2,y2,@(x,y)bar(x,y,1,'c'),'stairs')
1 comentario
Respuestas (1)
Tom Lane
el 24 de En. de 2013
When I try your commands after
rng(0)
data = 150 + 10*randn(200,1);
bin = 100:10:250;
I get the same cdf curve in the two figures. If you type
which stairs
do you see the one that is part of MATLAB or is there another one hanging around?
2 comentarios
Tom Lane
el 25 de En. de 2013
If I run my three lines of code, then your code with a "figure(2)" inserted before the second plotting command, I see both plots having (x=149.6995,y=0.5) on the blue curve. They look this way by eye and they show these values if I turn on the data cursor.
Notice that the two y axes on the same figure share the same x axis. You did substantial customization of the display. Could any of this have caused the x ticks for blue curve not to display, and to be different from the ones for the histogram? That's my only idea. Perhaps you can provide more code to reproduce both figures exactly and illustrate the problem.
Ver también
Categorías
Más información sobre Discrete Data Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!