R/generateRandomWalk.R

Defines functions .dataRW

.dataRW <- function(n, poisParam = 0.05, meanGap = 10, sdX = 1, sdY = 1) {
  changepoints <- rpois(n, poisParam)
  z <- rnorm(n, 0, sdX) + sample(c(-1,1), size = n, replace = TRUE) * changepoints * rnorm(n, mean = meanGap)
  y <- cumsum(z) + rnorm(n, 0, sdY)
  
  return(list(y = y, cp = which(changepoints > 0)))
}

Try the DeCAFS package in your browser

Any scripts or data that you put into this service are public.

DeCAFS documentation built on Jan. 6, 2023, 5:27 p.m.