eunif {EnvStats}R Documentation

Estimate Parameters of a Uniform Distribution


Estimate the minimum and maximum parameters of a uniform distribution.


  eunif(x, method = "mle")



numeric vector of observations. Missing (NA), undefined (NaN), and infinite (Inf, -Inf) values are allowed but will be removed.


character string specifying the method of estimation. The possible values are "mle" (maximum likelihood; the default), "mme" (method of moments), and "mmue" (method of moments based on the unbiased estimator of variance). See the DETAILS section for more information on these estimation methods.


If x contains any missing (NA), undefined (NaN) or infinite (Inf, -Inf) values, they will be removed prior to performing the estimation.

Let \underline{x} = (x_1, x_2, \ldots, x_n) be a vector of n observations from an uniform distribution with parameters min=a and max=b. Also, let x_{(i)} denote the i'th order statistic.


Maximum Likelihood Estimation (method="mle")
The maximum likelihood estimators (mle's) of a and b are given by (Johnson et al, 1995, p.286):

\hat{a}_{mle} = x_{(1)} \;\;\;\; (1)

\hat{b}_{mle} = x_{(n)} \;\;\;\; (2)

Method of Moments Estimation (method="mme")
The method of moments estimators (mme's) of a and b are given by (Forbes et al., 2011):

\hat{a}_{mme} = \bar{x} - \sqrt{3} s_m \;\;\;\; (3)

\hat{b}_{mme} = \bar{x} + \sqrt{3} s_m \;\;\;\; (4)


\bar{x} = \frac{1}{n} \sum_{i=1}^n x_i \;\;\;\; (5)

s^2_m = \frac{1}{n} \sum_{i=1}^n (x_i - \bar{x})^2 \;\;\;\; (6)

Method of Moments Estimation Based on the Unbiased Estimator of Variance (method="mmue")
The method of moments estimators based on the unbiased estimator of variance are exactly the same as the method of moments estimators given in equations (3-6) above, except that the method of moments estimator of variance in equation (6) is replaced with the unbiased estimator of variance:

\hat{a}_{mmue} = \bar{x} - \sqrt{3} s \;\;\;\; (7)

\hat{b}_{mmue} = \bar{x} + \sqrt{3} s \;\;\;\; (8)


s^2 = \frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})^2 \;\;\;\; (9)


a list of class "estimate" containing the estimated parameters and other information. See
estimate.object for details.


The uniform distribution (also called the rectangular distribution) with parameters min and max takes on values on the real line between min and max with equal probability. It has been used to represent the distribution of round-off errors in tabulated values. Another important application is that the distribution of the cumulative distribution function (cdf) of any kind of continuous random variable follows a uniform distribution with parameters min=0 and max=1.


Steven P. Millard (


Forbes, C., M. Evans, N. Hastings, and B. Peacock. (2011). Statistical Distributions. Fourth Edition. John Wiley and Sons, Hoboken, NJ.

Johnson, N. L., S. Kotz, and N. Balakrishnan. (1995). Continuous Univariate Distributions, Volume 2. Second Edition. John Wiley and Sons, New York.

See Also

Uniform, estimate.object.


  # Generate 20 observations from a uniform distribution with parameters 
  # min=-2 and max=3, then estimate the parameters via maximum likelihood. 
  # (Note: the call to set.seed simply allows you to reproduce this example.)

  dat <- runif(20, min = -2, max = 3) 

  #Results of Distribution Parameter Estimation
  #Assumed Distribution:            Uniform
  #Estimated Parameter(s):          min = -1.574529
  #                                 max =  2.837006
  #Estimation Method:               mle
  #Data:                            dat
  #Sample Size:                     20


  # Compare the three methods of estimation:

  eunif(dat, method = "mle")$parameters 
  #      min       max 
  #-1.574529  2.837006 
  eunif(dat, method = "mme")$parameters 
  #      min       max 
  #-1.988462  2.650737 
  eunif(dat, method = "mmue")$parameters 
  #      min       max 
  #-2.048721  2.710996 


  # Clean up

[Package EnvStats version 2.8.1 Index]