Main Content

unifit

Continuous uniform parameter estimates

Description

[aHat,bHat] = unifit(x) returns the maximum likelihood estimates (MLEs) of the continuous uniform distribution lower and upper endpoint parameters a and b, given the sample data in x.

[aHat,bHat,aCI,bCI] = unifit(x) also returns the 95% confidence intervals for the parameter estimates.

[aHat,bHat,aCI,bCI] = unifit(x,alpha) specifies the confidence level for the confidence intervals to be 100(1 – alpha)%.

example

Examples

collapse all

Generate 100 random numbers from the continuous uniform distribution with the lower endpoint parameter a=5 and upper endpoint parameter b=10.

rng(0,"twister") % For reproducibility
a = 5;
b = 10;
x = unifrnd(a,b,100,1);

Find the maximum likelihood estimate and 99% confidence intervals for the parameters.

[aHat,bHat,aCI,bCI] = unifit(x,0.01)
aHat = 
5.0595
bHat = 
9.8530
aCI = 2×1

    4.8336
    5.0595

bCI = 2×1

    9.8530
   10.0789

aHat and bHat are the MLEs of the lower and upper endpoint parameters, respectively. aCI and bCI contain the 99% confidence intervals. The value in the first row is the lower bound, and the value in the second row is the upper bound.

Input Arguments

collapse all

Sample data, specified as a numeric vector or matrix. When x is a matrix, the function computes parameter estimates (and confidence intervals, if specified) for the individual columns in x.

Data Types: single | double

Significance level for the confidence intervals, specified as a scalar in the range [0,1]. The confidence level is 100(1 – alpha)%, where alpha is the probability that the confidence intervals do not contain the true value. You can specify [] for alpha to use its default value of 0.05.

Data Types: single | double

Output Arguments

collapse all

Uniform lower endpoint parameter estimates, returned as a numeric row vector. When x is a matrix, aHat has length n, where n is the number of columns in x.

Uniform upper endpoint parameter estimates, returned as a numeric row vector. When x is a matrix, bHat has length n, where n is the number of columns in x.

Confidence intervals for the lower endpoint parameter estimates, returned as a 2-by-n numeric array. The first row of aCI contains lower confidence bound values, and the second row contains upper confidence bound values. When x is a vector, n = 1. When x is a matrix, n equals the number of columns in x.

Confidence intervals for the upper endpoint parameter estimates, returned as a 2-by-n numeric array. The first row of bCI contains lower confidence bound values, and the second row contains upper confidence bound values. When x is a vector, n = 1. When x is a matrix, n equals the number of columns in x.

Alternative Functionality

unifit is a function specific to the continuous uniform distribution. Statistics and Machine Learning Toolbox™ also offers the generic functions mle, fitdist, and paramci and the Distribution Fitter app, which support various probability distributions.

  • mle returns MLEs and the confidence intervals of MLEs for the parameters of various probability distributions. You can specify the probability distribution name or a custom probability density function.

  • Create a UniformDistribution probability distribution object by fitting the distribution to data using the fitdist function or the Distribution Fitter app. The object properties Lower and Upper store the parameter estimates. To obtain the confidence intervals for the parameter estimates, pass the object to paramci.

Version History

Introduced before R2006a