### Function Reference: `unifit`

statistics: paramhat = unifit (x)
statistics: [paramhat, paramci] = unifit (x)
statistics: [paramhat, paramci] = unifit (x, alpha)
statistics: [paramhat, paramci] = unifit (x, alpha, freq)

Estimate parameter and confidence intervals for the continuous uniform distribution.

`paramhat = unifit (x)` returns the maximum likelihood estimate (MLE) of the parameters a and b of the continuous uniform distribution given the data in x. x must be a vector.

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

`[…] = unifit (x, alpha, 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))`.

Further information about the continuous uniform distribution can be found at https://en.wikipedia.org/wiki/Continuous_uniform_distribution

See also: unifcdf, unifinv, unifpdf, unifrnd, unifstat

Source Code: unifit

### Example: 1

     ## Sample 2 populations from different continuous uniform distibutions
     rand ("seed", 5);    # for reproducibility
     r1 = unifrnd (2, 5, 2000, 1);
     rand ("seed", 6);    # for reproducibility
     r2 = unifrnd (3, 9, 2000, 1);
     r = [r1, r2];

     ## Plot them normalized and fix their colors
     hist (r, 0:0.5:10, 2);
     h = findobj (gca, "Type", "patch");
     set (h(1), "facecolor", "c");
     set (h(2), "facecolor", "g");
     hold on

     ## Estimate their probability of success
     a_bA = unifit (r(:,1));
     a_bB = unifit (r(:,2));

     ## Plot their estimated PDFs
     x = [0:10];
     y = unifpdf (x, a_bA(1), a_bA(2));
     plot (x, y, "-pg");
     y = unifpdf (x, a_bB(1), a_bB(2));
     plot (x, y, "-sc");
     xlim ([1, 10])
     ylim ([0, 0.5])
     legend ({"Normalized HIST of sample 1 with a=2 and b=5", ...
              "Normalized HIST of sample 2 with a=3 and b=9", ...
              sprintf("PDF for sample 1 with estimated a=%0.2f and b=%0.2f", ...
                      a_bA(1), a_bA(2)), ...
              sprintf("PDF for sample 2 with estimated a=%0.2f and b=%0.2f", ...
                      a_bB(1), a_bB(2))})
     title ("Two population samples from different continuous uniform distibutions")
     hold off