chi2gof function does not work with Gaussian mixture model

조회 수: 2 (최근 30일)
Anna Tuzova
Anna Tuzova 2020년 6월 24일
편집: Aditya Patil 2021년 2월 19일
When I try to test the null hypothesis that the data in the vector x are obtained from the Gaussian mixture model using the chi-square matching criterion, I get an error.
x = [trnd(20,1,50) trnd(4,1,100)+3];
GMModel = fitgmdist(x',2);
h = chi2gof(x, 'CDF', GMModel)
Error using chi2gof (line 216)
The 'cdf' value must be a ProbDist object, a function handle, or a cell array containing a function handle.

답변 (1개)

Aditya Patil
Aditya Patil 2021년 2월 19일
편집: Aditya Patil 2021년 2월 19일
You need to pass a function handle of the cdf function, for example,
h = chi2gof(x,'cdf',{@normcdf,mean(x),std(x)})
For your example, it would be
x = [trnd(20,1,50) trnd(4,1,100)+3]';
GMModel = fitgmdist(x,2);
h = chi2gof(x, 'CDF', @(y)(GMModel.cdf(y')))

Community Treasure Hunt

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

Start Hunting!

Translated by