---
title: "More Brownian Motion--Last Lab!"
author: "Math 365"
date: "April 25, 2016"
output: html_document
---

Submit your work to tleise@amherst.edu (and/or turn in by hand) by 4pm Friday.

In this lab we will do some further exploration of Brownian motion. 

## Multi-Dimensional Brownian Motion

Multi-dimensional Brownian motion can be constructed using independent one-dimensional Brownian motions for the coordinates of a vector-valued function $X_t=(X_t^{(1)}, \dots, X_t^{(n)})$. 

### Exercise 1

Update the R code from last week's lab to run simulations of 2-dimensional Brownian motion by generating two Brownian motions $X_t$ and $Y_t$. Plot the resulting path $(X_t,Y_t)$ in the $xy$-plane.

### Exercise 2 

Add a 3rd Brownian motion $Z_t$ to run simulations of 3-dimensional Brownian motion. Plot the resulting path using plot3D, which requires loading the plot3D package: in the RStudio window, click on Install in the Packages tab, then choose plot3D. It should then download and install the package; you may need to click on the box next to plot3D in the list of packages to actually load it.

```{r}
library("plot3D")
x<-(0:100)/6 # dummy vectors to illustrate 3D plotting function
y<-cos(x)
z<-sin(x)
lines3D(x,y,z,ticktype="detailed",main="3D Brownian motion simulation",colkey=FALSE)
```

## Martingales and Brownian Motion

For continuous-time stochastic processes, we say that $Y_t$ is a martingale with respect to filtration $\mathcal{F}_t=\{X_s: 0\le s\le t\}$ if it is $\mathcal{F}_t$-measurable, $\mathbb{E}|Y_t|<\infty$, and $E(Y_t|\,\mathcal{F}_s)=Y_s$ for all $s<t$.

Geometric Brownian motion can be defined as
 $$Y_t=e^{\mu t+\sigma X_t},$$ 
 where $X_t$ is a standard Brownian motion.
 
### Exercise 3

Calculate $\mathbb{E}[e^{\sigma X_t}]=\int_{-\infty}^\infty{e^{\sigma x}f(x)dx}$, given that $X_t$ is a standard Brownian motion, so $f(x)$ here is the density function for the normal distribution with mean 0 and variance $t$. As it's not an easy integral to do by hand, feel free to use Mathematica or Wolfram Alpha.

### Exercise 4

Calculate $E(Y_t|\,\mathcal{F}_s)$ for $t>s\ge0$, using the result from Exercise 3.

### Exercise 5

What condition on $\mu$ and $\sigma$ is required for a geometric Brownian motion $Y_t$ to be a martingale?