The Uniform Distribution.

Share:

Description

Density, distribution, quantile, random number generation and parameter estimation functions for the uniform distribution on the interval [a,b]. Parameter estimation can be based on an unweighted i.i.d. sample only and can be performed analytically or numerically.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
dUniform(x, a = 0, b = 1, params = list(a, b), ...)

pUniform(q, a = 0, b = 1, params = list(a, b), ...)

qUniform(p, a = 0, b = 1, params = list(a, b), ...)

rUniform(n, a = 0, b = 1, params = list(a, b), ...)

eUniform(X, w, method = c("analytic.MLE", "moments", "numerical.MLE"), ...)

lUniform(X, w, a = 0, b = 1, params = list(a, b), logL = TRUE, ...)

Arguments

x,q

A vector of quantiles.

a,b

Boundary parameters.

params

A list that includes all named parameters.

...

Additional parameters.

p

A vector of probabilities.

n

Number of observations.

X

Sample observations.

w

An optional vector of sample weights.

method

Parameter estimation method.

logL

logical;if TRUE, lUniform gives the log-likelihood, otherwise the likelihood is given.

Details

If a or b are not specified they assume the default values of 0 and 1, respectively.

The dUniform(), pUniform(), qUniform(),and rUniform() functions serve as wrappers of the standard dunif, punif, qunif, and runif functions in the stats package. They allow for the parameters to be declared not only as individual numerical values, but also as a list so parameter estimation can be carried out.

The uniform distribution has probability density function

p_x(x) = 1/(b-a)

for a ≤ x ≤ b. The analytic maximum likelihood parameter estimates are as given by Engineering Statistics Handbook. The method of moments parameter estimation option is also avaliable and the estimates are as given by Forbes et.al (2011), p.179.

The log-likelihood function for the uniform distribution is given by

l(a,b|x) = -n log(b-a)

Value

dUniform gives the density, pUniform the distribution function, qUniform the quantile function, rUniform generates random deviates, and eUniform estimates the parameters. lUniform provides the log-likelihood function.

Note

The analytical maximum likelihood estimation of the parameters a and b is calculated using the range and mid-range of the sample. Therefore, only unweighted samples are catered for in the eUniform distribution when the method analytic.MLE is selected.

Author(s)

Haizhen Wu and A. Jonathan R. Godfrey.
Updates and bugfixes by Sarah Pirikahu.

References

Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, volume 2, chapter 26, Wiley, New York.

Engineering Statistics Handbook

Forbes, C. Evans, M. Hastings, N. & Peacock, B. (2011) Statistical Distributions, 4th Ed, chapter 40, Wiley, New Jersey.

See Also

ExtDist for other standard distributions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Parameter estimation for a distribution with known shape parameters
X <- rUniform(n=500, a=0, b=1)
est.par <- eUniform(X, method="analytic.MLE"); est.par
plot(est.par)

# Histogram and fitted density
den.x <- seq(min(X),max(X),length=100)
den.y <- dUniform(den.x,a=est.par$a,b=est.par$b)
hist(X, breaks=10, probability=TRUE, ylim = c(0,1.2*max(den.y)))
lines(den.x, den.y, col="blue")  # Original data
lines(density(X), lty=2)         # Fitted curve

# Extracting boundary parameters
est.par[attributes(est.par)$par.type=="boundary"]

# log-likelihood
lUniform(X,param = est.par)

# Example of parameter estimation for a distribution with
# unknown parameters currently been sought after.