How to draw cumulative histogram?

97 visualizaciones (últimos 30 días)
Wenyi Xiao
Wenyi Xiao el 13 de Jul. de 2019
Respondida: infinity el 13 de Jul. de 2019
HI,
My bins = [ 10 10 20 40 50 60 70 80 80 80 90 90 90 100 100 100 100 100 ]
data = [ 4 8 14 35 49 55 66 74 76 78 82 84 90 92 94 96 98 100 ]
How can I draw cumulative probability histogram with these values?

Respuestas (2)

Bjorn Gustavsson
Bjorn Gustavsson el 13 de Jul. de 2019
Simplest would be something like this:
bins = [ 10 10 20 40 50 60 70 80 80 80 90 90 90 100 100 100 100 100 ];
data = [ 4 8 14 35 49 55 66 74 76 78 82 84 90 92 94 96 98 100 ];
stairs(data,bins)
% or
bar(data,bins)
HTH

infinity
infinity el 13 de Jul. de 2019
Hello,
You shoud do some tasks to approximate cumulative probability from your data. Then you just plot it. Below, will be a reference code
clear
My_bins = [ 10 10 20 40 50 60 70 80 80 80 90 90 90 100 100 100 100 100 ];
data = [ 4 8 14 35 49 55 66 74 76 78 82 84 90 92 94 96 98 100 ];
bin = unique(My_bins);
[N,EDGES] = histcounts(data,bin);
ndist = N / sum(N);
cdist = cumsum(ndist);
plot(0.5*(bin(1:end-1)+bin(2:end)), cdist);

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by