###################ͬ¼ ###################
par(mfrow=c(2,1))
seed(123)
plot(BM())

seed(321)  # һ¼
plot(BM())

#################### ˶ģ  #############
set.seed(123)
N <- 100   # ʱ[0,T]ָķ
T <- 1 
Delta <- T/N # ʱ
W <- numeric(N+1)  # ʼ W
t <- seq(0,T, length=N+1)
for(i in 2:(N+1))
        W[i] <- W[i-1] + rnorm(1) * sqrt(Delta)	
plot(t,W, type="l", main="˶" , ylim=c(-1,1))

############### β˶ģ ################
set.seed(123)
mu <- 1
sigma <- 0.5
x <- 10
N <- 100   # [0,T]ķָ
T <- 1 
Delta <- T/N # ʱ
W <- numeric(N+1) # ʼ W
t <- seq(0,T, length=N+1)
for(i in 2:(N+1))
        W[i] <- W[i-1] + rnorm(1) * sqrt(Delta)	
S <- x * exp((mu-sigma^2/2)*t + sigma*W)
plot(t,S,type="l",main="β˶")




