random_walk: Simulate a random walk

View source: R/random_walk.R

random_walkR Documentation

Simulate a random walk

Description

Simple function to simulate a random walk

Usage

random_walk(x = 1:100, y0 = 100, sd = 1, mu = 0)

Arguments

x

independent variable values (e.g. vector of time steps)

y0

Initial value of y

sd

Standard deviation of normal error distribution

mu

multiplicative drift parameter

Examples

## Not run: 
plot(random_walk(),type="l")
plot(random_walk(),random_walk(),type="l")
# Random walks can be pretty
x <- 1:1000
y1 <- random_walk(x)
y2 <- random_walk(x)
plot(y1,y2,type="l")
points(y1,y2,type="p",pch=16,col=rainbow(length(x)))

## End(Not run)

nikolaifish/bamExtras documentation built on July 21, 2023, 8:26 a.m.