simulation codes
-
rand follows uniform distribution between [0,1], randn follows normal distribution between [0,1].
-
rand(2,1), rand(2)
-
his(rand(100000,1))
-
icdf
-
icdf('Normal', rand(100000,1), 0.3,0.4)
-
A=icdf('exp', rand(100000,1), 0.5)
hist(A)
Multivariate Random Number
- mvnrnd([2;4][2 1;1 3])
- mvnrnd([2;4][2 1;1 3],5)
- A=mvnrnd([2;4][2 1;1 3],50000)
plot(A(:,1), A(:,2),'d')
** Simulating period by period**
Code
- Path is a matrix, in the last command, do remember to write "." after the Path(;,i), or Matlab will think it as a whole matrix transform, rather than for each element specified.
- "Nsim" is number of simulation
** The simulated discounted present value **
Statistic Inference
Exercise
Variance Reduction
- Antithetic Algorithm
Example
- Control Variable












网友评论