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