How to fit a long tail in histogram in one bin?
3 次查看(过去 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!