Chi-square distribution plot

조회 수: 1 (최근 30일)
Kash022
Kash022 2017년 7월 3일
답변: dpb 2017년 7월 3일
Hi All,
I want to plot the chi square distribution which I have computed. I have the below code which returns me the parameters but am unable to plot the distribution.
[h,p,st]= chi2gof(Id,'NBins',nBins,'Alpha',0.05)
h =
0
p =
0.2530
st =
chi2stat: 129.9011
df: 120
edges: [1x124 double]
O: [1x123 double]
E: [1x123 double]
Id is 1x2000 vector. nBins for me ~278. Please let me know how to plot the distribution. Thanks a lot!!

답변 (1개)

dpb
dpb 2017년 7월 3일
Because chi2gof returns bin edges, need to convert to centers --
x=filter([0.5 0.5],1,st.edges); x=x(2:end); % average successive edges for centers
bar(x,[st.O;st.E]','grouped') % put the two groups together for bar
legend('Observed','Expected') % tell who's who...

카테고리

Help CenterFile Exchange에서 Probability Distributions and Hypothesis Tests에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by