simNoiseMat: Simulate Noise

View source: R/simNoiseMat.R

simNoiseMatR Documentation

Simulate Noise

Description

Simulate a matrix composed of rows with different noise types.

Usage

simNoiseMat(samples = 100, noisetypes = list(white = 2, pink = 5, brown
  = 3), brown.type = "bm", mean = 5, sd = 1, r = 2,
  stayDead = FALSE)

Arguments

samples

the number of samples to be drawn

noisetypes

a list specifying the number of rows to be generated for each noise type

brown.type

the algorithm to generate brown noise, options: bm (Brown motion) and gbm (geometrical Brown motion; requires sde package)

mean

parameter for white and brown noise (type bm)

sd

parameter for white and brown noise (type bm)

r

parameter for brown noise (type gbm)

stayDead

once a time series hits zero or below, it stays at zero

Details

White noise is generated with rnorm and brown noise with cumsum(rnorm). Pink noise is generated with the noise function from the tuneR package. Brown noise can optionally be generated with geometric Brown motion via the GBM function in the sde package. Option stayDead allows simulating extinction events; i.e. once a value of zero or below has been hit, the row only takes zero values.

Value

a matrix where each row represents a distribution following a specified noise type

Examples

  # plot the power spectrum of pink noise
  ps <- powerspec(simNoiseMat(samples=100,noisetypes=list(white=0,pink=1,brown=0))[1,], plot=TRUE)
  # plot a matrix with mixed noise types
  mat <- simNoiseMat(samples=300,noisetypes=list(white=0,pink=30,brown=20))
  tsplot(mat,header="simulated noise")
  # Taylor law of brown noise
  t <- taylor(simNoiseMat(samples=300,noisetypes=list(white=0,pink=0,brown=50)),type="taylor")
  # Check generation of pink noise
  i <- identifyNoisetypes(simNoiseMat(samples=500,noisetypes=list(white=0,pink=10,brown=0)))

hallucigenia-sparsa/seqtime documentation built on Jan. 9, 2023, 11:53 p.m.