rmulti: Simple way to generate noise

Description Usage Arguments Value Author(s) References Examples

Description

Generates noise by selecting from a mixture distribution of normal densities with means, standard deviations and probabilities provided

Usage

1
rmulti(n, mean, sd, p)

Arguments

n

Size of the noise vector to be outputted

mean

Vector of means corresponding to each component density

sd

Vector of standard deviations corresponding to each component density

p

Probability of selecting from each component distribution

Value

Vector of random numbers

Author(s)

Yan-Xia Lin

References

no references

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (n, mean, sd, p) 
{
    x <- rnorm(n)
    u <- sample(1:length(mean), n, prob = p, replace = T)
    for (i in 1:length(mean)) x[u == i] = mean[i] + sd[i] * x[u == 
        i]
    return(x)
  }

MaskJointDensity documentation built on May 2, 2019, 8:28 a.m.