R: Zero-mean, unit-variance version of standard distributions
U-utils
R Documentation
Zero-mean, unit-variance version of standard distributions
Description
Density, distribution function, quantile function and random number
generation for the shifted and scaled U of the
(location-)scale family input X sim F_X(x mid oldsymbol β)
- see References.
Since the normalized random variable U is one of the main building blocks of
Lambert W \times F distributions, these functions are wrappers used
by other functions such as dLambertW or
rLambertW.
numeric vector (deprecated); parameter oldsymbol β of
the input distribution. See check_beta on how to specify
beta for each distribution.
distname
character; name of input distribution; see
get_distnames.
use.mean.variance
logical; if TRUE it uses mean and variance
implied by oldsymbol β to do the transformation (Goerg 2011).
If FALSE, it uses the alternative definition from Goerg (2016)
with location and scale parameter.
p
vector of probability levels
n
number of samples
Value
dU evaluates the pdf at y, pU evaluates the
cdf, qU is the quantile function, and rU generates random
samples from U.
Examples
# a zero-mean, unit variance version of the t_3 distribution.
curve(dU(x, beta = c(1, 1, 3), distname = "t"), -4, 4,
ylab = "pdf", xlab = "u",
main = "student-t \n zero-mean, unit variance")
# cdf of unit-variance version of an exp(3) -> just an exp(1)
curve(pU(x, beta = 3, distname = "exp"), 0, 4, ylab = "cdf", xlab = "u",
main = "Exponential \n unit variance", col = 2, lwd = 2)
curve(pexp(x, rate = 1), 0, 4, add = TRUE, lty = 2)
# all have (empirical) variance 1
var(rU(n = 1000, distname = "chisq", beta = 2))
var(rU(n = 1000, distname = "normal", beta = c(3, 3)))
var(rU(n = 1000, distname = "exp", beta = 1))
var(rU(n = 1000, distname = "unif", beta = c(0, 10)))
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(LambertW)
Loading required package: MASS
Loading required package: ggplot2
This is 'LambertW' version 0.6.4. Please see the NEWS file and citation("LambertW").
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/LambertW/U-utils.Rd_%03d_medium.png", width=480, height=480)
> ### Name: U-utils
> ### Title: Zero-mean, unit-variance version of standard distributions
> ### Aliases: U-utils dU pU qU rU
> ### Keywords: datagen distribution univar
>
> ### ** Examples
>
>
> # a zero-mean, unit variance version of the t_3 distribution.
> curve(dU(x, beta = c(1, 1, 3), distname = "t"), -4, 4,
+ ylab = "pdf", xlab = "u",
+ main = "student-t \n zero-mean, unit variance")
> # cdf of unit-variance version of an exp(3) -> just an exp(1)
> curve(pU(x, beta = 3, distname = "exp"), 0, 4, ylab = "cdf", xlab = "u",
+ main = "Exponential \n unit variance", col = 2, lwd = 2)
> curve(pexp(x, rate = 1), 0, 4, add = TRUE, lty = 2)
> # all have (empirical) variance 1
> var(rU(n = 1000, distname = "chisq", beta = 2))
[1] 0.2495207
> var(rU(n = 1000, distname = "normal", beta = c(3, 3)))
[1] 0.9811253
> var(rU(n = 1000, distname = "exp", beta = 1))
[1] 0.9671871
> var(rU(n = 1000, distname = "unif", beta = c(0, 10)))
[1] 0.972511
>
>
>
>
>
>
> dev.off()
null device
1
>