chi2gof two sample test for integer arrays of different sizes?
古いコメントを表示
Hey all,
I have 2 integer arrays, one of size 1x25 and the other of 1x26. I have been told to use the chi squared test in order to find how statistically different my data is. But I don't know how to do this, with ttest you could just do ttest2(Arr1, Arr2). Can someone please help me out, thanks!
回答 (5 件)
Wayne King
2012 年 6 月 21 日
chi2gof is for one sample. You can test each vector separately against a specific distribution, but not against each other.
x = randn(100,1);
[h,p] = chi2gof(x,'cdf',@normcdf)
y = rand(100,1);
[h1,p1] = chi2gof(y,'cdf',@normcdf)
You see in the second case you reject the null hypothesis.
Are you just looking for a nonparametric two-sample test? How about ranksum()?
Wayne King
2012 年 6 月 21 日
You can certainly specifiy a discrete distribution to use with chi2gof, by specifing the bins (edges) and expected counts.
Now that you have described your use case more, it sounds to me like you may want crosstab() . crosstab() uses a chi-square test for independence of two samples.
For example:
x1 = unidrnd(3,50,1);
x2 = unidrnd(3,50,1);
[table,chi2,p] = crosstab(x1,x2)
See:
for example.
Annick van der Hoest
2012 年 6 月 21 日
0 投票
2 件のコメント
Wayne King
2012 年 6 月 21 日
yes, I think you need to use equal sample sizes. I don't know your data, so I can't suggest a principled way to make the sample sizes equal.
Annick van der Hoest
2012 年 6 月 21 日
Lucjan
2014 年 12 月 4 日
0 投票
It is not correct direction. Crosstab assumes there is a meaning for a pair (x,y) that is why it needs the same number of samples. You are calling for two sample chi-square distribution, which, as far as I chucked, is not implemented in MATLAB. But you should be able to implement it by yourself based on: http://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/chi2samp.htm
カテゴリ
ヘルプ センター および File Exchange で Chi-Square Distribution についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!