Learn R Programming

GROAN (version 1.3.1)

noiseInjector.unif: Inject Uniform Noise

Description

This function adds to the passed phenotypes array noise sampled from a uniform distribution with the specified range.
The function can interest the totality of the passed phenotype array or a random subset of it (commanded by subset parameter).

Usage

noiseInjector.unif(phenotypes, min = 0, max = 1, subset = 1)

Value

An array, of the same size as phenotypes, where uniform noise has been added to the original phenotype values.

Arguments

phenotypes

an array of numbers.

min, max

lower and upper limits of the distribution. Must be finite.

subset

integer in [0,1], the proportion of original dataset to be injected

See Also

Other noiseInjectors: noiseInjector.dummy(), noiseInjector.norm(), noiseInjector.swapper()

Examples

Run this code
#a sinusoid signal
phenos = sin(seq(0,5, 0.1))
plot(phenos, type='p', pch = 16, main='Original (black) vs. Injected (red), 100% affected')

#adding normal noise to all samples
phenos.noise = noiseInjector.unif(phenos, min=0.1, max=0.3)
points(phenos.noise, type='p', col='red')

#adding noise only to 30% of the samples
plot(phenos, type='p', pch = 16, main='Original (black) vs. Injected (red), 30% affected')
phenos.noise.subset = noiseInjector.unif(phenos, min=0.1, max=0.3, subset = 0.3)
points(phenos.noise.subset, type='p', col='red')

Run the code above in your browser using DataLab