CDF for Gaussian Mixture Distribution
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I am ultimately trying to calculate the KS-test statistic for a mixture Gaussian distribution for a data set 'TestData' I have tried to find the appropriate syntax for this but I cannot seem to get it correct. Below is my code with the error messages. I have also included my 1 mixture Gaussian solution as a guide. I didn't think it would be much different. I still think it might not be. Thank you for any help you cn provide.
% Mixture Code:
for j=1:10000 if rand <=0.4 TestData(j) = normrnd(0,2); else TestData(j) = normrnd(10,2); end end
% Fit TestData to Gaussian 2 Mixture Model mpd01 = fitgmdist(TestData, 2);
% Calculate the CDF value for the Mixture Distribution at a given TestData % value test_cdf = [TestData,cdf(TestData,mpd01.mu, mpd01.sigma, mpd01.p)];
% Calculate hypothesis test and p-value for the KS test [h,p] = kstest(test_cdf, 'Alpha', 0.01);
% --------------- Error Message
%No appropriate method, property, or field 'sigma' for class 'gmdistribution'.
%Error in classreg.learning.internal.DisallowVectorOps/subsref (line 21) % [varargout{1:nargout}] = builtin('subsref',this,s);
%Error in BurrTest (line 10) %test_cdf = [TestData,cdf(TestData,mpd01.mu, mpd01.sigma, mpd01.p)]
% Singular Gaussian Code
% Normal Distribution
pd18 = fitdist(TestData,'normal'); test_cdf = [TestData,cdf('normal',TestData,pd18.mu,pd18.sigma)]; [h,p] = kstest(test_cdf, 'Alpha', 0.01); pValKStest(18) = p;
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Hypothesis Tests에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!