### Function Reference: `wblfit`

statistics: paramhat = wblfit (x)
statistics: [paramhat, paramci] = wblfit (x)
statistics: [paramhat, paramci] = wblfit (x, alpha)
statistics: […] = wblfit (x, alpha, censor)
statistics: […] = wblfit (x, alpha, censor, freq)
statistics: […] = wblfit (x, alpha, censor, freq, options)

Estimate parameters and confidence intervals for the Weibull distribution.

`muhat = wblfit (x)` returns the maximum likelihood estimates of the parameters of the Weibull distribution given the data in x. `paramhat(1)` is the scale parameter, lambda, and `paramhat(2)` is the shape parameter, k.

`[paramhat, paramci] = wblfit (x)` returns the 95% confidence intervals for the parameter estimates.

`[…] = wblfit (x, alpha)` also returns the `100 * (1 - alpha)` percent confidence intervals for the parameter estimates. By default, the optional argument alpha is 0.05 corresponding to 95% confidence intervals. Pass in `[]` for alpha to use the default values.

`[…] = wblfit (x, alpha, censor)` accepts a boolean vector, censor, of the same size as x with `1`s for observations that are right-censored and `0`s for observations that are observed exactly. By default, or if left empty, `censor = zeros (size (x))`.

`[…] = wblfit (x, alpha, censor, freq)` accepts a frequency vector, freq, of the same size as x. freq typically contains integer frequencies for the corresponding elements in x, but it can contain any non-integer non-negative values. By default, or if left empty, `freq = ones (size (x))`.

`[…] = wblfit (…, options)` specifies control parameters for the iterative algorithm used to compute the maximum likelihood estimates. options is a structure with the following field and its default value:

- `options.Display = "off"`
- `options.MaxFunEvals = 400`
- `options.MaxIter = 200`
- `options.TolX = 1e-6`

Further information about the Weibull distribution can be found at https://en.wikipedia.org/wiki/Weibull_distribution

See also: wblcdf, wblinv, wblpdf, wblrnd, wbllike, wblstat

Source Code: wblfit

### Example: 1

     ## Sample 3 populations from 3 different Weibull distibutions
     rande ("seed", 1);    # for reproducibility
     r1 = wblrnd(2, 4, 2000, 1);
     rande ("seed", 2);    # for reproducibility
     r2 = wblrnd(5, 2, 2000, 1);
     rande ("seed", 5);    # for reproducibility
     r3 = wblrnd(1, 5, 2000, 1);
     r = [r1, r2, r3];

     ## Plot them normalized and fix their colors
     hist (r, 30, [2.5 2.1 3.2]);
     h = findobj (gca, "Type", "patch");
     set (h(1), "facecolor", "c");
     set (h(2), "facecolor", "g");
     set (h(3), "facecolor", "r");
     ylim ([0, 2]);
     xlim ([0, 10]);
     hold on

     ## Estimate their lambda parameter
     lambda_kA = wblfit (r(:,1));
     lambda_kB = wblfit (r(:,2));
     lambda_kC = wblfit (r(:,3));

     ## Plot their estimated PDFs
     x = [0:0.1:15];
     y = wblpdf (x, lambda_kA(1), lambda_kA(2));
     plot (x, y, "-pr");
     y = wblpdf (x, lambda_kB(1), lambda_kB(2));
     plot (x, y, "-sg");
     y = wblpdf (x, lambda_kC(1), lambda_kC(2));
     plot (x, y, "-^c");
     hold off
     legend ({"Normalized HIST of sample 1 with λ=2 and k=4", ...
              "Normalized HIST of sample 2 with λ=5 and k=2", ...
              "Normalized HIST of sample 3 with λ=1 and k=5", ...
              sprintf("PDF for sample 1 with estimated λ=%0.2f and k=%0.2f", ...
                      lambda_kA(1), lambda_kA(2)), ...
              sprintf("PDF for sample 2 with estimated λ=%0.2f and k=%0.2f", ...
                      lambda_kB(1), lambda_kB(2)), ...
              sprintf("PDF for sample 3 with estimated λ=%0.2f and k=%0.2f", ...
                      lambda_kC(1), lambda_kC(2))})
     title ("Three population samples from different Weibull distibutions")
     hold off