Correct histogram - with hist,histc ?

1 次查看(过去 30 天)
x y
x y 2014-11-29
编辑: x y 2014-11-29
My textbook say,the correct histogram is that when the bars width is same in the histogram graph.
And show how to make correct histogram in ML for two type of data.
1.) when the classes are the same width
frekvenci = hist(data,k);
[frekvenci, reprezentatntclasses] = hist(data,k);
I tried in example,but I dont know is good way because I didnt get figure with graph ?!?
clear,clc
data = rand(100,1)*750;
k = 10;
pt = hist(data,k)
[pt, rt] = hist(data,k)
2.) when classes isnt the same width
ht = [. .. ..] %binranges
frekvencie = histc(data,ht)
width = ht(2:end) - ht(1:end-1) %width classes
nor = frekvencie(1:end-1)./width %normaziation fkrev.classes
bar(ht,nor,'histc')
in concrate example I tried:
clear,clc
data = rand(100,1)*750;
ht = [0 100 200 300 500 ];
pt = histc(data,ht)
sum(pt)
sirky = ht(2:end) - ht(1:end-1)
upt = pt(1:end-1)./sirky %here I get dimension error ?!? how can I solve this error
bar(ht,upt,'histc')

回答(1 个)

x y
x y 2014-11-29
编辑:x y 2014-11-29
I found other example,that was:
ht = [170 290 350 410 470 530 710]
pt = [ 8 12 11 8 5 6]
sirky = ht(2:end) - ht(1:end-1)
upt = pt./sirky
bar(ht, [upt 0], 'histc')
and now what I want,it is good ?
ht = [0 100 200 300 500 ];
pt = histc(data,ht)
pt = pt'
length(pt)
sirky = ht(2:end) - ht(1:end-1)
upt = pt(1:end-1)./sirky
bar(ht,[upt 0],'histc') % this [upt 0] is always there are this 0 ??

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by