Learn R Programming

SNSchart (version 1.4.0)

getDist: Random Observations Generator

Description

Random observations generator selected from several distributions with user defined mean and variance.

Usage

getDist(
  n,
  dist,
  mu,
  sigma,
  par.location = 0,
  par.scale = 1,
  par.shape = 1,
  dist.par = NULL,
  rounding.factor = NULL
)

Arguments

n

scalar. Number of observations to be generated.

dist

character string. Select from:

  • "Uniform: Continuous Uniform distribution .

  • "Normal": Normal distribution (default).

  • "Normal2": Squared Normal distribution (also known as Chi-squared).

  • "DoubleExp": Double exponential distribution (also known as Laplace distribution).

  • "DoubleExp2": Double exponential squared distribution from a DoubleExp(0,1).

  • "LogNormal": Lognormal distribution.

  • "Gamma": Gamma distribution.

  • "Weibull": Weibull distribution.

  • "t": Student-t distribution.

mu

scalar. Expected value of the desired distribution.

sigma

scalar. Standard deviation of the desired distribution.

par.location

scalar. Location parameter of the desired distribution. Default 0**.

par.scale

scalar. Scale parameter of the desired distribution. Default 1**.

par.shape

scalar. Shape parameter of the desired distribution, Default 1.

dist.par

vector. Overwrite par.location, par.scale, par.shape. Depends on the distribution (default NULL):

  • "Uniform: no matter how is defined always gives numbers between 0 and 1.

  • "Normal": c(location, scale).

  • "Normal2": c(location, scale).

  • "DoubleExp": c(location, scale).

  • "DoubleExp2": c(location, scale).

  • "LogNormal": c(location, scale).

  • "Gamma": c(scale, shape).

  • "Weibull": c(shape, scale).

  • "t": c(degrees of freedom).

rounding.factor

scalar. positive value that determine the range between two consecutive rounded values.

Value

A vector x with n observations generated following the selected distribution with its parameters.

**Note

  • For "Lognormal", par.location and par.scale correspond to the location and scale parameters of the normal distribution that generales the lognormal. Hence, in this case they are the logmean and the logsigma parameters

  • For "Normal2" and "DoubleExp2", par.location and par.scale correspond correspond to the location and scale parameters of the normal and double exponential that are used to generates their squared forms.

Examples

Run this code
# NOT RUN {
getDist(1, "Normal", 0, 1)
# }

Run the code above in your browser using DataLab