Normalizing a histogram
이전 댓글 표시
Hello,
I've plotted a histogram of some data. Here it is http://dl.dropbox.com/u/54057365/All/departure%20time.JPG
How can remove the gaps between the bars? Should I be using a histogram? But how can you normalize the measurements on the y axis in a histogram?
Many thanks
DepartureTimes = load('Departure Times (hr).txt')
h = hist(DepartureTimes,24);
h = h/sum(h);
bar(h, 'DisplayName', 'Depature Times');
legend('show');
xlim([5 25])
댓글 수: 1
Jan
2013년 7월 11일
[lost image] Here the expected effect appears: The image was deleted from the server, such that the question lost its meaning.
Please, TMW, add the service to host images on the Answers servers soon. Otherwise the quality of this forum as a database of solutions will suffer from the implicit expiration of the linked images.
채택된 답변
추가 답변 (4개)
Wayne King
2012년 3월 31일
0 개 추천
yes, you are doing the correct thing. You can use dfittool to fit a Gamma distribution, which you can use estimate the parameters of a chi-square PDF.
dfittool will also overlay the fitted pdf on the data.
The alpha parameter in a gamma is dof/2 and the beta parameter is 2.
You can generate code for your fit from dfittool and export the fit to the workspace.
Wayne King
2012년 3월 31일
I'm saying that if you fit a gamma, you get an alpha and a beta parameter. You can use that to see if a chi-square is appropriate (and not a more general gamma) and if so, get the dof parameter.
For example:
R = chi2rnd(5,1e3,1); %chi-square 5 dof
phat = mle(R,'distribution','Gamma');
phat(1) is the alpha parameter, but that is the dof/2 for a chi- square
Therefore
round(2*phat(1))
Gives you an estimate of the dof parameter for a chi-square.
phat(2) should always be close to 2 (if it isn't that is a indication that chi-square is not a good fit)
You can also use fitdist()
pd = fitdist(R,'gamma');
For this example, I get:
gamma distribution
a = 2.50903
b = 1.99592
which indicates a chi-square PDF with 5 dof.
댓글 수: 2
John
2012년 3월 31일
Wayne King
2012년 3월 31일
Do you have some a priori reason that is must be chi-square and not a more general gamma? At first glance, the beta value indicates that a more general gamma is more appropriate here.
Image Analyst
2012년 3월 31일
To remove the gaps between the bars, you set the ' BarWidth ' property to 1:
bar(binsNumbers, CountData, 'BarWidth', 1);
By setting the BarWidth to between 0 and 1 you can go from having huge gaps between the bars (very skinny bars) to having full width bars (bars touch each other with no gap at all).
Harish Chandra
2012년 9월 4일
0 개 추천
I have a question, I know it has been some time since the last post in this thread but I am posting it here since it is relevant... How do you obtained the goodness of fit of gamma distrubution fitted to any data? For example the chi^2 or the R^2 value maybe using chi2gof or something similar?
Thanks for your help. Harish
카테고리
도움말 센터 및 File Exchange에서 Gamma Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!