I know that if I take take a brownian motion of, say, 30 steps of standard deviation 1, then the standard deviation of my endpoint will be sqrt(30). But what if the standard deviation of the 30 steps is defined by a function? How do I relate the endpoint standard deviation to that function?
An example in R, first with a standard fixed volatility random walk.
library(xts)
mysd <- 0.1 / sqrt(255) # small sd so that we don't walk too far
genwalk <- function(stepsizes) {i <- 1; for(x in stepsizes) i <- c(i, i[length(i)] * exp(x)); return(i)} # random walk function - geometric
acc <- matrix(0, 1000)
plot(genwalk(rnorm(30, 0, mysd)), type = "l", ylim = c(0.88, 1.12), col = "#0000001A")
for(x in 1:1000) {walk <- genwalk(rnorm(30, 0, mysd)); acc[x] <- last(walk); lines(walk, col = "#0000001A")}
title("1000 30-step random walks with step size 0.1/sqr(255)")
No surprises here:
> sd(acc)
[1] 0.03484051
> mysd * sqrt(30)
[1] 0.03429972
> title("1000 30-step random walks with step size 0.1/sqr(255)")
> library(moments)
> kurtosis(acc)
[1] 3.048236
> mean(acc)
[1] 1.000664
So I know how to get from a standard deviation of x to the standard deviation of a 30-step walk: multiple x by the square root of the number of steps.
But what if x is a function rather than a constant? How do I then relate the function to the endpoint standard deviation? Let's say my function is a decay weighting of length 30 with half life 10:
decay <- exp((-log(2) / 10) * 30:1) # exponential decay, 30 steps
> plot(genwalk(rnorm(30, 0, mysd) * decay), type = "l", ylim = c(0.88, 1.12), col = "#0000001A")
> for(x in 1:1000) {walk <- genwalk(rnorm(30, 0, mysd) * decay); acc[x] <- last(walk); lines(walk, col = "#0000001A")}
> title("Random walks with step size 0.1/sqr(255) * decay weighting")
> sd(acc)
[1] 0.01645629
> mysd
[1] 0.006262243
> kurtosis(acc)
[1] 2.882403
> mean(acc)
[1] 1.000137
So it looks like the endpoints are still nicely normally distributed (mean ~ 0, kurtosis ~ 3), but I have no clue how to relate the standard deviation of the endpoints, that is sd(acc) above = 0.1645629 to mysd which was the step size multiplier for the decay function.
Basically: how do I get from the decay function which was applied to the standard deviation of step sizes, to the standard deviation of the endpoints?
last
supposed to do? $\endgroup$mysd * sqrt(sum(decay^2))
just replace your decay weights for the ones you'd prefer and you get to compute the answer). $\endgroup$