How to fit a long tail in histogram in one bin?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Mark
am 5 Jun. 2013
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 Kommentare
Mark
am 5 Jun. 2013
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')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!