50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


asymmetry.measures (version 0.2)

r.sample: Switch between a range of available random number generators.

Description

Generate a random sample of size n out of a range of available distributions.

Usage

r.sample(s, dist, p1=0, p2=1)

Arguments

s

A scalar which specifies the size of the random sample drawn.

dist

Character string, used as a switch to the user selected distribution function (see details below).

p1

A scalar. Parameter 1 (vector or object) of the selected distribution.

p2

A scalar. Parameter 2 (vector or object) of the selected distribution.

Value

A vector of random values at the user specified points s.

Details

Based on user-specified argument dist, the function returns a random sample of size s from the corresponding distribution.

Supported distributions (along with the corresponding dist values) are:

  • weib: The weibull distribution is implemented as f(s;p1,p2)=p1p2(sp2)p11exp{(sp2)p1} with s0 where p1 is the shape parameter and p2 the scale parameter.

  • lognorm: The lognormal distribution is implemented as f(s)=1p2s2πe(logsp1)22p22 where p1 is the mean and p2 is the standard deviation of the distirbution.

  • norm: The normal distribution is implemented as f(s)=1p22πe(sp1)22p22 where p1 is the mean and the p2 is the standard deviation of the distirbution.

  • uni: The uniform distribution is implemented as f(s)=1p2p1 for p1sp2.

  • cauchy: The cauchy distribution is implemented as f(s)=1πp2{1+(sp1p2)2} where p1 is the location parameter and p2 the scale parameter.

  • fnorm: The half normal distribution is implemented as 2f(s)1 where f(s)=1sd2πes22sd2, and sd=π/2/p1.

  • normmixt:The normal mixture distribution is implemented as

    f(s)=p11p2[2]2πe(sp2[1])22p2[2]2+(1p1)1p2[4]2πe(sp2[3])22p2[4]2

    where p1 is a mixture component(scalar) and p2 a vector of parameters for the mean and variance of the two mixture components p2=c(mean1,sd1,mean2,sd2).

  • skewnorm: The skew normal distribution with parameter p1 is implemented as f(s)=2ϕ(s)Φ(p1s).

  • fas: The Fernandez and Steel distribution is implemented as f(s;p1,p2)=2p1+1p1{ft(s/p1;p2)I{s0}+ft(p1s;p2)I{s<0}} where ft(x;ν) is the p.d.f. of the t distribution with ν=5 degrees of freedom. p1 controls the skewness of the distribution with values between (0,+) and p2 denotes the degrees of freedom.

  • shash: The Sinh-Arcsinh distribution is implemented as f(s;μ,p1,p2,τ)=cer2/22π1p2121+z2 where r=sinh(sinh(z)(p1)), c=cosh(sinh(z)(p1)) and z=((sμ)/p2). p1 is the vector of skewness, p2 is the scale parameter, μ=0 is the location parameter and τ=1 the kurtosis parameter.

References

Bagkavos D., Patil P.N., Wood A.T.A. (2016), A Numerical Study of the Power Function of a New Symmetry Test. In: Cao R., Gonzalez Manteiga W., Romo J. (eds) Nonparametric Statistics. Springer Proceedings in Mathematics and Statistics, vol 175, Springer.

See Also

d.sample, q.sample, p.sample

Examples

Run this code
# NOT RUN {
selected.r <- "norm" #select Normal as the distribution
shape <- 2  # specify shape parameter
scale <- 1  # specify scale parameter
n <- 100    # specify sample size
r.sample(n,selected.r,shape,scale)  # calculate CDF at the designated point
# }

Run the code above in your browser using DataLab