simulateDist: Data simulation for different distributions.

Description Usage Arguments Value See Also Examples

View source: R/utilityFunctions.R

Description

Wrapper function to simulate data from different distribution with different parameter settings.

Usage

1
2
3
4
5
6
7
8
simulateDist(
  x,
  dist = c("unif", "norm", "bin", "cat_norm", "cat_unif"),
  m = NULL,
  std = 1,
  categories = NULL,
  prob = NULL
)

Arguments

x

The number [integer] of observations to simulate.

dist

Name of distribution [string] from which the observations are drawn. 'norm' is the normal distribution, 'unif' the uniform distribution 'bin' the binomial distribution, "cat_norm" samples categorical variables according to a normal distribution and "cat_unif" according to a uniform distribution. For "cat_norm", length(category)/2 is used mean for the normal distribution unless specified otherwise.

m

Mean of the normal distribution [double]/the mean between min and max for the uniform distribution [double]/ the rank of the category to be used as mean for "cat_norm" [integer].

std

Standard deviation of the normal distribution or the distance of min/max from the mean for the uniform distribution [double].

categories

Number of categories [integer] for simulating categorical variables (for distr="cat_norm" or "cat_unif").

prob

Probability [double] of success for each trial (for distr="bin").

Value

Numeric vector of length [x] with the sampled values

See Also

runif, rnorm, rbinom for documentation of the underlying distributions.

Examples

1
2
3
4
5
normal <- simulateDist(x=10, dist="norm", m=2, std=4)
cat_normal <- simulateDist(x=10, dist="cat_norm", categories=5)
cat_uniform <- simulateDist(x=10, dist="cat_unif", categories=5)
uniform <- simulateDist(x=10, dist="unif", m=4, std=1)
binomial <- simulateDist(x=10, dist="bin", prob=0.4)

PhenotypeSimulator documentation built on July 16, 2021, 5:06 p.m.