How to fit a long tail in histogram in one bin?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I have a vector X with some time values in sec. I want to make a histogram of its distribution, but since it has a long tail it is really hard for one to perceive the scale. My vector X has values from 0 to 16000 sec, but I would like the hist to be printed until the value of 2010 (with interval of 30sec) and the rest observations to be stored all together as >2010 or something equivalent. The code I use so far is:
xint=30; % my interval
edges=(30-xint:xint:2010); % 30*67=2010
[n,bin]=histc(X,edges);
n1=0;
for i=1:size(X,2)
if Χ(i)>xint*67 % only right tail
n1=n1+1
end
end
n(end)=n(end)+n1;
figure
bar(edges,n,'histc')
but what I get is not what I want to get, since the bars are not connected to each other and by counting them it is like the observations of every other interval are missing...
Any suggestion?
Thanks,
Iro
댓글 수: 0
채택된 답변
Mark
2013년 6월 5일
You could loop through your X values and make a temporary XT that assigns everything large to 2010:
XT=X;
XT(XT>xint*67) = xint*67;
[n,bin]=histc(XT,edges);
bar, etc.
댓글 수: 2
Mark
2013년 6월 5일
Not sure why. Are you sure your data has values in all the bins? When I generate some random data, and run it through the code, it looks like it has 67 bins with the extras in the last slot:
X = abs(randn(1,1000)*1000+300);
xint=30; % my interval
edges=(30-xint:xint:2010); % 30*67=2010
XT=X;
XT(XT>xint*67) = xint*67;
[n,bin]=histc(XT,edges);
figure
bar(edges,n,'histc')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!