# Terminal Variance in the Heston Model

I am trying to understand the basics of financial models.

Random Walk as a model for asset prices.

We use gaussian random numbers to generate a Gaussian Random walk. The variance of the terminal value (cumulative sum of random steps) divided by the square root of the number of steps is $1$ due to central limit theorem.

$S_0=0$ and $\displaystyle S_{n}=\sum _{j=1}^{n}Z_{j}$

$\displaystyle Var\left(\dfrac{S_n}{\sqrt{n}}\right)=1$

Black Scholes Model

Asset price follows a geometric brownian motion.

The variance of the terminal value ($\ln {\frac {S_{t}}{S_{0}}}$) is:

$\displaystyle \ln {\frac {S_{t}}{S_{0}}}=\left(\mu -{\frac {\sigma ^{2}}{2}}\,\right)t+\sigma W_{t}\,$

$\displaystyle Var\left(\ln {\frac {S_{t}}{S_{0}}}\right)=\left(\mu -{\frac {\sigma ^{2}}{2}}\,\right)^2t+\sigma^2t,$

The simulations also return values as expected from these closed form equations.

Heston Model

$\displaystyle dS_t=\mu S_t dt + \sqrt{v_t}S_t dW_{1,t}$

$\displaystyle dv_t=\kappa (\theta-v_t)dt + \sigma\sqrt{v_t} dW_{2,t}$

where $\mathbb{E}[dW_{1,t}dW_{2,t}]=\rho dt$

From what I understand, there is no closed form solution for $Var(S_t)$. Now, when I simulate

clear;clc;

s0=100; % Initial stock price
mu=0; % expected return
v0=0.05; % Initialising value for variance
kappa=1.6; % mean reversion rate AND 2*kappa*theta geq sigma^2
theta=0.1; % long run variance
sigma=0.2; % volatility of variance
rho = 0.0; % Correlation between Stock and its Volatility Process

n_sim=10^4; % count of simulations
n=1000; % number of steps

dt=1/n;
ss=ones(n_sim,n)*s0;
vv=ones(n_sim,n)v0;
for i=1:n_sim % multiple simulated paths
z=randn(n,2); % To generate two independent N(0,1) variables
for t=2:n % single path generation
Z_v = z(:,1);
Z_s = rho
z(:,1)+sqrt(1-rho^2)*z(:,2);
% Discretize the log variance
vv(i,t)=vv(i,t-1)exp((1/vv(i,t-1))(kappa*(theta-vv(i,t-1))-(sigma^2/2))dt+(sigmasqrt(dt/vv(i,t-1))*Z_v(t)));
% Discretize the log stock price
ss(i,t)=ss(i,t-1)*exp((mu-(vv(i,t-1)/2))*dt+sqrt(vv(i,t-1)*dt)*Z_s(t));
end
end
x=log(ss(:,n)/s0);
vv1=vv(:,n);
mean_vv1=mean(vv1); % comes out as 0.09

var_sn=var(x); % comes out as 0.075

I get a value of $0.075$. What "meaning" do I draw from it ?

Its not anywhere near the long run variance ($\theta$) or $v_t|t=1$. When should the long run variance be achieved ?

From the equations of the model it is clear that $v_t$ is the instantaneous variance of the log-returns, not the terminal annualised variance of the log-asset price.
Put differently, you are you confusing $$v_t \approx \text{var}(\ln(S_{t+\delta t}/S_t))/\delta t$$ with $$\text{var}(\ln(S_t))/t$$ presumably because in the Black-Scholes framework these are both equal to $\sigma^2$.
If you want to look at something near $v_0$ or $\theta$ you should take the mean of the process $(v_t)_{t \geq 0}$ itself (vv in your above code) for different times $t$ and see how it starts from $v_0$ to gradually reach $\theta$.