normfit
              Estimate parameters and confidence intervals for the normal distribution.
 [muhat, sigmahat] = normfit (x) estimates the
 parameters of the normal distribution given the data in x.  muhat
 is an estimate of the mean, and sigmahat is an estimate of the standard
 deviation.
 [muhat, sigmahat, muci, sigmaci] = normfit
 (x) returns the 95% confidence intervals for the mean and standard
 deviation estimates in the arrays muci and sigmaci, respectively.
normfit supports only 2 input arguments, x and
 alpha.  Optional arguments censor, freq, and options
 can be used only when x is a vector.
 [] for
 alpha to use the default values.
 (SUM (freq) - 1) / SUM (freq).  This correction is needed
 because normfit normally computes sigmahat using an unbiased
 variance estimator when there is no censored data.  When there is censoring
 in the data, the correction is not needed, since normfit does not use
 the unbiased variance estimator in that case.
 fminsearch which is used internally to compute MLEs for censored data.
 By default, it uses the following options:
 options.Display = "off"
 options.MaxFunEvals = 400
 options.MaxIter = 200
 options.TolX = 1e-6
 See also: normcdf, norminv, normpdf, normrnd, normlike, normstat
Source Code: normfit
| 
 ## Sample 3 populations from 3 different normal distibutions
 randn ("seed", 1);    # for reproducibility
 r1 = normrnd (2, 5, 5000, 1);
 randn ("seed", 2);    # for reproducibility
 r2 = normrnd (5, 2, 5000, 1);
 randn ("seed", 3);    # for reproducibility
 r3 = normrnd (9, 4, 5000, 1);
 r = [r1, r2, r3];
 ## Plot them normalized and fix their colors
 hist (r, 15, 0.4);
 h = findobj (gca, "Type", "patch");
 set (h(1), "facecolor", "c");
 set (h(2), "facecolor", "g");
 set (h(3), "facecolor", "r");
 hold on
 ## Estimate their mu and sigma parameters
 [muhat, sigmahat] = normfit (r);
 ## Plot their estimated PDFs
 x = [min(r(:)):max(r(:))];
 y = normpdf (x, muhat(1), sigmahat(1));
 plot (x, y, "-pr");
 y = normpdf (x, muhat(2), sigmahat(2));
 plot (x, y, "-sg");
 y = normpdf (x, muhat(3), sigmahat(3));
 plot (x, y, "-^c");
 ylim ([0, 0.5])
 xlim ([-20, 20])
 hold off
 legend ({"Normalized HIST of sample 1 with mu=2, σ=5", ...
          "Normalized HIST of sample 2 with mu=5, σ=2", ...
          "Normalized HIST of sample 3 with mu=9, σ=4", ...
          sprintf("PDF for sample 1 with estimated mu=%0.2f and σ=%0.2f", ...
                  muhat(1), sigmahat(1)), ...
          sprintf("PDF for sample 2 with estimated mu=%0.2f and σ=%0.2f", ...
                  muhat(2), sigmahat(2)), ...
          sprintf("PDF for sample 3 with estimated mu=%0.2f and σ=%0.2f", ...
                  muhat(3), sigmahat(3))}, "location", "northwest")
 title ("Three population samples from different normal distibutions")
 hold off
                     | 
