Fitting parameters of a uniform distribution from two or more quantiles


get.unif.par returns the parameters of a uniform distribution where the pth percentiles match with the quantiles q.


get.unif.par(p = c(0.025, 0.975), q, plot = TRUE, scaleX = c(0.1, 0.9), ...)



numeric, single value or vector of probabilities.


numeric, single value or vector of quantiles corresponding to p.


logical, if TRUE the graphical diagnostics will be plotted (default value is TRUE)


numerical vector of the length 2 containing values (from the open interval (0, 1)) for scaling quantile-axis (relevant only if plot = TRUE). The smaller the left value, the further the graph is extrapolated within the lower percentile, the greater the right value, the further it goes within the upper percentile.


further arguments passed to the functions plot and points (relevant only if plot = TRUE)


The number of probabilities and the number of quantiles must be identical and should be at least two. Using the default p, the three corresponding quantiles are the 2.5th percentile, the median and the 97.5th percentile, respectively.

Parameters of the uniform distribution are estimated exactly.

The items of the probability vector p should lie between 0 and 1.


Returns fitted parameters of a uniform distribution.


It should be noted that there might be deviations between the estimated and the theoretical distribution parameters in certain circumstances. This is because the estimation of the parameters is based on a numerical optimization method and depends strongly on the initial values. In addition, one must always keep in mind that a distribution for different combinations of parameters may look very similar. Therefore, the optimization method cannot always find the "right" distribution, but a "similar" one.

If the function terminates with the error massage "convergence error occurred or specified tolerance not achieved", one may try to set the convergence tolerance to a higher value. It is yet to be noted, that good till very good fits of parameters could only be obtained for tolerance values that are smaller than 0.001.


Matthias Greiner (BfR),
Katharina Schueller (STAT-UP Statistical Consulting),
Natalia Belgorodski (STAT-UP Statistical Consulting)


q <- stats::qunif(p = c(0.025, 0.975), min = 0, max = 5)
get.unif.par(q = q)
get.unif.par(q = q, scaleX = c(0.001, 0.999))

q <- stats::qunif(p = c(0.025, 0.975), min=-6, max = 5)
get.unif.par(q = q)

Want to suggest features or report bugs for Use the GitHub issue tracker. Vote for new features on Trello.

comments powered by Disqus