Brownian Motion
Definición:
Un proceso estocástico \(\{B(t), t\geq 0\}\) es un movimiento Browniano si cumple las siguientes propiedades:
1.- \(B(0) = 0\)
2.- \(\{B(t), t\geq 0\}\) tiene incrementos independientes y estacionarios.
3.- Para \(t>0\), B(t) tiene distribución normal con media cero y varianza \(t\).
Simulación:
Sea
\[0 = t_0 < t_1 < t_2 < , ..., < t_{n-1} < t_n = T\] \
Consideremos una partición sobre \([0, T]\) dada por \(\Delta t = T/n\), tal que
\[0 = t_0 < t_1=\Delta t < t_2 = 2\Delta t < , ..., < t_{n-1} = (n-1)\Delta t< t_n = n \Delta t = T\] \
entonces para simular trajectorias del movimiento Browniano consideremos los incrementos
\[B(t_1) - B(t_0) \sim N(0, t_1 - t_0) = N(0, \Delta t - 0) = \sqrt{\Delta t} N(0, 1)\] \[ B(t_2) - B(t_1) \sim N(0, t_2 - t_1) = N(0, 2\Delta t-\Delta t) = \sqrt{\Delta t} N(0, 1)\] \[ \vdots \] \[ B(t_n) - B(t_{n-1}) \sim N(0, t_n - t_{n-1}) = N(0, n\Delta t-(n-1)\Delta t) = \sqrt{\Delta t} N(0, 1)\] \
Sumando los incrementos se tiene que
\[ B(t_n) - B(t_0) \sim \sum_{i=1}^{n} \sqrt{\Delta t} N(0, 1)\]
dado que \(B(t_0) = 0\) entonces
\[ B(t_n) \sim \sqrt{\Delta t} \sum_{i=1}^{n} N(0, 1)\]
y dado que \(\sqrt{\Delta t} = T/n\), finalmente tenemos que
\[ B(t_n) \sim \sqrt{\frac{T}{n}} \sum_{i=1}^{n} N(0, 1)\]
# Function para simular una caminata aleatoria simple
<- function(t, nSteps, nReps){
simMB <- t/ nSteps
dt #
<- matrix(nrow=nReps, ncol=(nSteps+1))
simMat 1] <- 0
simMat[ ,for(i in 1:nReps){
for(j in 2:(nSteps + 1)){
<- simMat[i,j-1] + sqrt(dt)*rnorm(1,0,1)
simMat[i,j]
}
}<- c('Rep', sapply(0:nSteps, function(i) paste('S',i,sep='')))
names <- data.frame('Rep'=1:nReps, simMat)
df colnames(df) <- names
return(df)
}
Ejemplo 1: Una trayectoria del Movimiento Browniano
# valores
<- 1000
t <- 1000
nSteps <- 1
nReps
<- simMB(t, nSteps, nReps)
bm1
# data
<- bm1 %>%
df pivot_longer(!Rep, names_to='Step', values_to='value') %>%
mutate(t = as.numeric(substring(Step,2,10))*t/nSteps,
Rep = as.character(Rep))
head(df)
## # A tibble: 6 x 4
## Rep Step value t
## <chr> <chr> <dbl> <dbl>
## 1 1 S0 0 0
## 2 1 S1 0.629 1
## 3 1 S2 0.332 2
## 4 1 S3 -0.312 3
## 5 1 S4 0.0981 4
## 6 1 S5 -0.789 5
# valores teóricos
<- data.frame('t'=seq(from=0, to=1, length=nSteps+1)*t) %>%
moments mutate('mean' = 0,
'sd_inf' = mean - 2*sqrt(t),
'sd_sup' = mean + 2*sqrt(t))
# Gráfico del Movimiento Browniano
options(repr.plot.width=16, repr.plot.height=8)
<- ggplot(df, mapping=aes(x=t, y=value, color=Rep)) +
p1 geom_line() +
geom_step(moments, mapping=aes(x=t,y=mean),col='red',size=0.7, alpha=0.5) +
geom_step(moments, mapping=aes(x=t,y=sd_sup),col='blue',size=0.7,linetype = "dashed") +
geom_step(moments, mapping=aes(x=t,y=sd_inf),col='blue',size=0.7,linetype = "dashed") +
labs( title = paste(nReps, "Trajectoria(s) del MB")) +
theme(legend.position = "none") +
scale_colour_grey(start = 0.2,end = 0.8)
#coord_cartesian(xlim = c(0, tmax))
p1
Ejemplo 2: Mil trayectorias del movimiento Browniano
# valores
<- 1000
t <- 1000
nSteps <- 1000
nReps
<- simMB(t, nSteps, nReps)
bm1
# data
<- bm1 %>%
df pivot_longer(!Rep, names_to='Step', values_to='value') %>%
mutate(t = as.numeric(substring(Step,2,10))*t/nSteps,
Rep = as.character(Rep))
# valores teóricos
<- data.frame('t'=seq(from=0, to=1, length=nSteps+1)*t) %>%
moments mutate('mean' = 0,
'sd_inf' = mean - 2*sqrt(t),
'sd_sup' = mean + 2*sqrt(t))
# Gráfico del Movimiento Browniano
options(repr.plot.width=16, repr.plot.height=8)
<- ggplot(df, mapping=aes(x=t, y=value, color=Rep)) +
p1 geom_line() +
geom_step(moments, mapping=aes(x=t,y=mean),col='red',size=0.7, alpha=0.5) +
geom_step(moments, mapping=aes(x=t,y=sd_sup),col='blue',size=0.7,linetype = "dashed") +
geom_step(moments, mapping=aes(x=t,y=sd_inf),col='blue',size=0.7,linetype = "dashed") +
labs( title = paste(nReps, "Trajectoria(s) del MB")) +
theme(legend.position = "none") +
scale_colour_grey(start = 0.2,end = 0.8)
#coord_cartesian(xlim = c(0, tmax))
p1
Movimiento Browniano en dos dimensiones
# Movimiento Browniano en dos dimensiones
<- function(base, n.steps){
plot.BM2d
<- base
df <- df %>%
df_2d gather(key='t',value='valor',-Rep) %>%
filter(Rep == 1 | Rep== 2) %>%
spread(Rep, valor) %>%
rename(Rep1 = '1', Rep2='2')%>%
mutate(t = as.numeric(substring(t,2,10))) %>%
arrange(t) %>%
filter(t <= n.steps)
<- ggplot(df_2d,aes(x=Rep1,y=Rep2))+
b2 geom_point(color="blue") +
geom_point(df_2d%>%filter(t == 1),mapping=aes(x=Rep1,y=Rep2),color="green") +
geom_point(df_2d%>%filter(t == max(t)),mapping=aes(x=Rep1,y=Rep2),color="red") +
geom_path() +
theme(axis.title.x = element_blank(),
axis.title.y = element_blank(),
axis.text.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.x=element_blank(),
axis.ticks.y=element_blank())
return(b2)
}
Ejemplo 1
# Ejemplo 1:
<- 1
t <- 10000 # número de pasos
n.steps <- 1000 # número de trayectorias
n.sim
# Gráfico
<- simMB(t, n.steps, n.sim)
df <- plot.BM2d(df, n.steps)
p3 p3