Created
September 15, 2017 13:47
-
-
Save pkofod/10e31b7cf341083453e106ce382ef9af to your computer and use it in GitHub Desktop.
tauchen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tauchen(ρ, σₛ, m, N) | |
const Φ = normcdf # CDF of standard normal | |
s̃₁, s̃ₙ = -m*σₛ, m*σₛ # end points | |
s̃ = linspace(s̃₁, s̃ₙ, N) # grid | |
w = (s̃[2]-s̃[1])/2 # half distance between grid points | |
F = zeros(N, N) # empty transition matrix | |
F[:, 1] = Φ.((s̃[1]-ρ.*s̃+w)/sqrt(σₛ)) | |
F[:, N] = 1-Φ.((s̃[end]-ρ.*s̃-w)/sqrt(σₛ)) | |
for j = 2:N-1 | |
for i = 1:N | |
F[i, j] = Φ.((s̃[j]-ρ*s̃[i]+w)/sqrt(σₛ))-Φ.((s̃[j]-ρ*s̃[i]-w)/sqrt(σₛ)) | |
end | |
end | |
F | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment