r.sample {asymmetry.measures} | R Documentation |

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

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

`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. |

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;p_1,p_2)= \frac{p_1}{p_2} ≤ft (\frac{s}{p_2}\right )^{p_1-1} \exp ≤ft \{- ≤ft (\frac{s}{p_2}\right )^{p_1} \right \}*with

*s ≥ 0*where*p_1*is the shape parameter and*p_2*the scale parameter.lognorm: The lognormal distribution is implemented as

*f(s) = \frac{1}{p_2s√{2π}}e^{-\frac{(log s -p_1)^2}{2p_2^2}}*where

*p_1*is the mean and*p_2*is the standard deviation of the distirbution.norm: The normal distribution is implemented as

*f(s) = \frac{1}{p_2√{2 π}}e^{-\frac{ (s - p_1)^2 }{ 2p_2^2 }}*where

*p_1*is the mean and the*p_2*is the standard deviation of the distirbution.uni: The uniform distribution is implemented as

*f(s) = \frac{1}{p_2-p_1}*for

*p_1 ≤ s ≤ p_2*.cauchy: The cauchy distribution is implemented as

*f(s)=\frac{1}{π p_2 ≤ft \{1+( \frac{s-p_1}{p_2})^2\right \} }*where

*p_1*is the location parameter and*p_2*the scale parameter.fnorm: The half normal distribution is implemented as

*2 f(s)-1*where

*f(s) = \frac{1}{sd√{2 π} }e^{-\frac{s^2}{2 sd^2 }},*and

*sd=√{π/2}/p_1*.normmixt:The normal mixture distribution is implemented as

*f(s)=p_1\frac{1}{p_2[2] √{2π} } e^{- \frac{ (s - p_2[1])^2}{2p_2[2]^2}} +(1-p_1)\frac{1}{p_2[4]√{2π}} e^{-\frac{(s - p_2[3])^2}{2p_2[4]^2 }}*where

*p1*is a mixture component(scalar) and*p_2*a vector of parameters for the mean and variance of the two mixture components*p_2= c(mean1, sd1, mean2, sd2)*.skewnorm: The skew normal distribution with parameter

*p_1*is implemented as*f(s)=2φ(s)Φ(p_1s)*.

fas: The Fernandez and Steel distribution is implemented as

*f(s; p_1, p_2) = \frac{2}{p_1+\frac{1}{p_1}} ≤ft \{ f_t(s/p_1; p_2) I_{\{s ≥ 0\}} + f_t(p_1s; p_2)I_{\{s<0 \}}\right \}*where

*f_t(x;ν)*is the p.d.f. of the*t*distribution with*ν = 5*degrees of freedom.*p_1*controls the skewness of the distribution with values between*(0, +∞)*and*p_2*denotes the degrees of freedom.shash: The Sinh-Arcsinh distribution is implemented as

*f(s;μ, p_1, p_2, τ) = \frac{ce^{-r^2/2}}{√{2π }} \frac{1}{p_2} \frac{1}{2} √{1+z^2}*where

*r=\sinh(\sinh(z)-(-p_1))*,*c=\cosh(\sinh(z)-(-p_1))*and*z=((s-μ)/p2)*.*p_1*is the vector of skewness,*p_2*is the scale parameter,*μ=0*is the location parameter and*τ=1*the kurtosis parameter.

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

.

Dimitrios Bagkavos and Lucia Gamez Gallardo

R implementation and documentation: Dimitrios Bagkavos <dimitrios.bagkavos@gmail.com> , Lucia Gamez Gallardo <gamezgallardolucia@gmail.com>

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

[Package *asymmetry.measures* version 0.2 Index]