Open in the MATLAB editor: g03ga_example
function g03ga_example fprintf('g03ga example results\n\n'); x = [2.7, 3.2, 4.5, 4.8; 3.9, 3.8, 5.9, 6.2; 4.8, 4.1, 6.8, 5.5; 3.1, 3.5, 4.3, 4.6; 3.4, 3.7, 5.1, 5.6; 3.1, 3.4, 4.1, 4.7; 4.6, 4.4, 6.6, 6.1; 3.1, 3.3, 4.0, 4.9; 3.8, 3.7, 4.7, 4.9; 5.2, 4.9, 8.2, 6.9; 3.9, 3.8, 5.2, 5.4; 4.1, 4.0, 5.6, 5.6; 5.7, 5.1, 7.0, 6.3; 3.0, 3.2, 4.5, 5.0; 2.9, 3.3, 4.5, 5.1; 3.4, 3.3, 4.4, 5.0; 4.0, 4.2, 5.2, 5.4; 3.0, 3.0, 4.6, 5.0; 4.0, 4.1, 5.9, 5.8; 3.0, 3.2, 4.4, 5.1; 3.6, 3.6, 5.3, 5.4; 3.1, 3.2, 4.6, 5.0; 3.2, 3.3, 5.4, 5.3; 3.0, 3.4, 4.2, 4.7; 3.8, 4.0, 6.9, 6.7]; [m,n] = size(x); ng = int64(2); prob = zeros(m,ng); prob(1:12,1) = 1; prob(13:m,2) = 1; isx = zeros(n, 1, 'int64'); nvar = int64(n); sopt = int64(2); sds = nvar; tol = 0; [prob, niter, w, g, s, f, loglik, ifail] = ... g03ga( ... x, isx, nvar, ng, sopt, sds, tol, 'prob', prob); mtitle = 'Mixing proportions'; matrix = 'General'; diag = ' '; [ifail] = x04ca( ... matrix, diag, w', mtitle); fprintf('\n'); mtitle = 'Group means'; [ifail] = x04ca( ... matrix, diag, g, mtitle); fprintf('\n'); mtitle = 'Pooled Variance-covariance matrix'; [ifail] = x04ca( ... matrix, diag, s, mtitle); fprintf('\n'); mtitle = 'Densities'; [ifail] = x04ca( ... matrix, diag, f, mtitle); fprintf('\n'); mtitle = 'Membership probabilities'; [ifail] = x04ca( ... matrix, diag, prob, mtitle); fprintf('\nNumber of iterations = %5d\n', niter); fprintf( 'Log-likelihood = %10.4f\n:', loglik);
g03ga example results Mixing proportions 1 2 1 0.4798 0.5202 Group means 1 2 1 4.0041 3.3350 2 3.9949 3.4434 3 5.5894 4.9870 4 5.4432 5.3602 Pooled Variance-covariance matrix 1 2 3 4 1 0.4539 0.2891 0.6075 0.3413 2 0.2891 0.2048 0.4101 0.2490 3 0.6075 0.4101 1.0648 0.6011 4 0.3413 0.2490 0.6011 0.3759 Densities 1 2 1 2.5836E-01 1.1853E-02 2 3.7065E-07 1.1241E-01 3 5.3069E-03 1.8080E-06 4 4.2461E-01 2.8584E-05 5 5.0387E-02 1.1544E+00 6 1.1260E+00 7.2224E-02 7 2.0911E+00 2.1224E-02 8 5.7856E-03 1.3227E+00 9 1.1609E+00 2.9411E-02 10 8.9826E-02 2.4260E-05 11 3.0170E-01 1.0106E+00 12 1.2930E+00 3.5422E-01 13 2.8644E-02 6.7851E-07 14 2.0759E-02 3.1690E+00 15 7.6461E-02 1.5231E+00 16 3.0279E-04 8.4017E-01 17 5.6101E-01 4.6699E-05 18 2.6573E-05 6.4442E-01 19 2.1250E+00 5.1006E-02 20 8.6822E-04 2.7626E+00 21 1.9223E-01 2.3971E+00 22 1.2469E-02 2.8179E+00 23 1.8389E-02 5.3572E-01 24 1.2409E+00 9.6489E-03 25 2.1037E-05 4.8674E-02 Membership probabilities 1 2 1 9.5018E-01 4.9823E-02 2 3.3259E-06 1.0000E+00 3 9.9961E-01 3.8664E-04 4 9.9992E-01 7.9913E-05 5 3.8999E-02 9.6100E-01 6 9.3270E-01 6.7295E-02 7 9.8881E-01 1.1190E-02 8 4.1252E-03 9.9587E-01 9 9.7252E-01 2.7479E-02 10 9.9969E-01 3.0805E-04 11 2.1722E-01 7.8278E-01 12 7.6938E-01 2.3062E-01 13 9.9997E-01 2.6937E-05 14 6.1133E-03 9.9389E-01 15 4.4189E-02 9.5581E-01 16 3.5006E-04 9.9965E-01 17 9.9990E-01 9.7029E-05 18 4.0270E-05 9.9996E-01 19 9.7380E-01 2.6202E-02 20 3.0204E-04 9.9970E-01 21 6.9471E-02 9.3053E-01 22 4.1603E-03 9.9584E-01 23 3.0839E-02 9.6916E-01 24 9.9116E-01 8.8421E-03 25 4.1534E-04 9.9958E-01 Number of iterations = 14 Log-likelihood = -29.6831 :