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
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.
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
# 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.
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ExtDist)
Attaching package: 'ExtDist'
The following object is masked from 'package:stats':
BIC
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ExtDist/Uniform.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Uniform
> ### Title: The Uniform Distribution.
> ### Aliases: Uniform dUniform eUniform lUniform pUniform qUniform rUniform
>
> ### ** Examples
>
> # 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
Parameters for the Uniform distribution.
(found using the analytic.MLE method.)
Parameter Type Estimate
a boundary 0.00814111
b boundary 0.99876210
> 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"]
$a
[1] 0.00814111
$b
[1] 0.9987621
>
> # log-likelihood
> lUniform(X,param = est.par)
[1] 4.711635
>
> # Example of parameter estimation for a distribution with
> # unknown parameters currently been sought after.
>
>
>
>
>
> dev.off()
null device
1
>