Reader question: The Heston model makes volatility itself random, but a naive Euler simulation can create a negative variance. How can an algorithm simulate the same stochastic-volatility idea without letting a quantity called variance become impossible?
The Andersen Quadratic-Exponential, or QE, scheme attacks this as a distribution problem rather than a clipping problem. The Heston variance process is a square-root diffusion with a known conditional mean and variance. Instead of taking one Gaussian Euler step and repairing negative values afterwards, QE builds a positive approximation whose first two conditional moments match those of the true variance transition. It then switches between two approximating distributions because one shape is not accurate in every part of the state space.
This article owns the Heston variance-transition simulation problem: current variance + Heston parameters + time step + random numbers → a non-negative next variance and a coupled asset-price step suitable for Monte Carlo pricing and risk calculations.
It does not own Heston calibration, Fourier inversion, the estimation of historical volatility, or the choice of a derivative to trade. Those are separate jobs. The purpose here is computational: how a continuous-time square-root variance model becomes a practical simulation algorithm, how to test it, and how to know when the simulation is lying.
This is public mathematical education about numerical finance. It is not investment advice or a recommendation to use the Heston model for any security.
1. Start with the risk-neutral Heston equations
Under a standard risk-neutral specification, the asset and variance evolve as:
dSt = (r−q)Stdt + √vtStdWtS
and:
dvt = κ(θ−vt)dt + ξ√vtdWtv,
with:
dWSdWv = ρdt.
The parameters have clear mathematical jobs:
- κ controls how quickly variance mean-reverts;
- θ is the long-run variance level;
- ξ is volatility of variance, often called vol-of-vol;
- ρ couples asset shocks and variance shocks;
- v0 is initial variance.
The problem is the square root. The continuous-time CIR-type variance process is non-negative, but a discrete Gaussian Euler approximation does not automatically preserve that property.
2. Why naive Euler can produce negative variance
A simple Euler step is:
vt+Δ ≈ vt + κ(θ−vt)Δ + ξ√vt√Δ Z,
where Z is standard normal.
If vt is small, the random term can dominate the drift and push the numerical value below zero. The continuous process did not become negative; the discretisation did.
One can clip negative values to zero, reflect them, or use full truncation inside the coefficients. Those fixes are useful benchmarks, but each changes the discrete transition distribution and can create pricing bias.
QE asks a different question: what positive distribution has approximately the right conditional shape and exactly the right first two moments?
3. The exact conditional moments are the information QE preserves
For a time step Δ, let the current variance be v. The CIR transition has conditional mean:
m = θ + (v−θ)e−κΔ.
Its conditional variance is:
s² = [vξ²e−κΔ/κ](1−e−κΔ) + [θξ²/(2κ)](1−e−κΔ)².
QE compresses these into the dimensionless ratio:
ψ = s²/m².
This single number says how dispersed the next variance is relative to the square of its mean.
When ψ is small, the transition is concentrated away from zero. When ψ is large, the true CIR transition is highly skewed and can carry substantial probability near zero. Those two regimes need different approximating shapes.
4. Regime A: a quadratic transformation of a Gaussian
For sufficiently small ψ, QE uses a squared shifted normal variable:
v′ = a(b + Z)²,
where Z ~ N(0,1).
The constants a and b are chosen so that:
E[v′] = m
and:
Var(v′) = s².
One standard parameterisation used in Andersen’s construction sets:
b² = 2/ψ − 1 + √(2/ψ)√(2/ψ − 1)
and:
a = m/(1+b²).
Because a square is non-negative, this branch cannot generate negative variance.
The name quadratic in Quadratic-Exponential comes from this branch.
5. Regime B: a point mass at zero plus an exponential tail
When ψ is large, the conditional variance distribution is more skewed and the quadratic-normal approximation becomes poor. QE switches to a distribution with:
- a probability mass at zero;
- an exponential positive tail.
Set:
p = (ψ−1)/(ψ+1)
and:
β = (1−p)/m.
Draw U ~ Uniform(0,1). A standard version of the branch is:
v′ = 0, if U ≤ p,
otherwise:
v′ = −(1/β) ln[(1−U)/(1−p)].
Again the first two moments match m and s². The point mass lets the approximation represent a transition that spends meaningful probability near the boundary.
The name exponential in Quadratic-Exponential comes from this branch.
6. Why one approximation is not enough
This is the deeper algorithmic idea.
A single Gaussian approximation is convenient but structurally wrong near zero. A single exponential approximation is poorly shaped when variance is concentrated around a positive mean. QE first calculates the state-dependent quantity ψ, then routes the transition through the approximation that better matches the shape of the exact CIR law.
So QE is not merely “a better random-number formula.” It is a state-dependent numerical decision rule.
The branch threshold is a numerical design parameter. Andersen’s original study analyses practical choices and shows that a stable switch can provide high efficiency over realistic parameter sets. A production implementation should record its chosen threshold rather than burying it as an unexplained constant.
7. The Feller condition matters, but not in the simplistic way people sometimes say
The variance process is often discussed with the Feller inequality:
2κθ ≥ ξ².
When the strict form is satisfied, the CIR variance stays away from the zero boundary under the classical conditions. If it is violated, zero may be attainable.
That does not mean the Heston model automatically ceases to exist, and it does not mean every numerical method must fail. It means the behaviour near zero becomes more important.
This is exactly where naive Gaussian discretisation struggles and where QE’s two-regime construction earns its value.
8. Sampling variance correctly is only half the job
The asset return and variance shock are correlated through ρ. A simulation must therefore update the log asset price in a way that is consistent with the variance step.
Write:
Xt = ln St.
Then:
dXt = (r−q−½vt)dt + √vtdWtS.
A useful decomposition is:
dWS = ρdWv + √(1−ρ²)dW⊥.
The correlated part can be related to the variance transition, while the orthogonal part requires an independent normal draw. Andersen’s schemes construct an asset-step approximation using the variance endpoints and carefully selected coefficients so the joint transition has low bias.
This matters because a simulator can have an excellent marginal variance distribution and still price options badly if it mishandles the asset–variance correlation.
9. Why martingale correction is a separate diagnostic
Under the risk-neutral measure with deterministic rates and dividends:
E[STe−(r−q)T] = S0.
A discrete simulation can violate this even if every variance step looks reasonable. The violation can arise from the exponential transformation used for the asset, discretised integrated variance, or correlation terms.
Andersen discusses martingale-corrected variants because small conditional biases in the log-price update can accumulate.
A practical validation test is therefore:
martingale error = Monte Carlo mean of discounted forward-adjusted ST − S0.
The error should be statistically compatible with zero at the resolution required by the use case.
10. Inputs and outputs of a QE simulation engine
Inputs can include:
- spot price;
- risk-free and dividend curves;
- Heston parameters κ, θ, ξ, ρ and v0;
- maturity;
- time grid;
- number of paths;
- QE branch threshold;
- asset-step variant and martingale correction;
- random-number generator;
- seed or scrambling policy;
- payoff specification.
Outputs can include:
- simulated variance paths;
- simulated asset paths;
- derivative-price estimate;
- Monte Carlo standard error;
- martingale residual;
- branch-use frequencies;
- fraction of near-zero variance steps;
- time-step convergence table;
- benchmark error versus semi-analytic Heston prices.
11. A minimal QE variance algorithm
- Read current variance v.
- Compute m and s² from the exact CIR conditional moments.
- Compute ψ = s²/m².
- If ψ is below the branch threshold, use the quadratic-normal transition.
- Otherwise use the zero-mass-plus-exponential transition.
- Generate the next variance v′ ≥ 0.
- Update the log asset with the chosen correlated QE asset step.
- Apply any martingale correction required by that variant.
- Repeat across time steps and paths.
- Discount payoffs and compute sampling error.
The algorithm is short. The validation burden is not.
12. Evidence polarity
Evidence for confidence includes non-negative variance by construction, correct recovery of the analytical conditional mean and variance in large simulation samples, small martingale residuals, option prices converging toward trusted Heston Fourier benchmarks as the time grid is refined, stable results across realistic parameter regions, and Monte Carlo standard errors shrinking at the expected square-root rate with path count.
Evidence against confidence includes persistent pricing bias that does not shrink with smaller Δ, large forward/martingale error, strong dependence on the arbitrary branch threshold, wrong conditional variance moments, unstable behaviour when the Feller condition is violated, correlations inconsistent with ρ, or apparently accurate prices that are produced only because two numerical errors cancel.
13. Counterexample: clipping Euler at zero can look fine until it does not
Suppose variance is usually far from zero. A full-truncation or clipping Euler scheme may agree closely with QE for a plain option.
Now increase vol-of-vol ξ or reduce κθ so the process spends more time near zero. The frequency and duration of boundary interactions rise, and the discretisation choice can materially change option values.
Falsifier: run the same calibrated parameters through full truncation, QE and a trusted benchmark over progressively smaller time steps. If the coarse-grid agreement disappears, the original match was accidental.
14. Counterexample: correct variance moments but wrong joint dynamics
A programmer can implement the QE variance transition perfectly and then update the asset with an independent Gaussian shock, forgetting the ρ coupling.
The marginal variance diagnostics pass. The implied-volatility skew does not.
Falsifier: estimate the simulated covariance between asset-return and variance innovations and compare it with the intended correlation structure. Then price products that are sensitive to the leverage effect.
15. Counterexample: a martingale error hides inside a plausible option price
A discretised asset step can bias the forward level upward while another approximation biases convexity downward. One option may price close to a benchmark by coincidence.
Falsifier: test the discounted asset martingale directly and benchmark a grid of strikes and maturities rather than one price.
16. Counterexample: time-step convergence can be non-uniform
A scheme may work well for at-the-money European options but converge more slowly for barrier, digital or very short-dated payoffs because those payoffs amplify path or boundary errors.
Falsifier: do not validate the engine only on smooth vanilla payoffs. Include discontinuous or path-sensitive benchmarks if those contracts are within scope.
17. Counterexample: calibrated parameters can sit in a numerically difficult region
Calibration optimisers can find parameter combinations with high vol-of-vol, extreme correlation or weak mean reversion because they fit a smile well. A simulation scheme validated only on comfortable textbook parameters may then be used outside its tested region.
Falsifier: map pricing error over the full parameter envelope admitted by calibration, not only the final best-fit point.
18. Alternatives
Full-truncation Euler is simple, fast and useful as an independent benchmark, but can require smaller time steps.
Exact Broadie–Kaya simulation avoids time-discretisation bias for the Heston model by sampling exact affine transition objects, but numerical inversion and integrated-variance sampling make it computationally heavier.
Alfonsi-type positivity-preserving schemes provide another family of carefully designed square-root diffusion discretisations.
Fourier pricing avoids path simulation for many European-style claims because Heston has a known characteristic function.
PDE methods are attractive for low-dimensional products and can provide deterministic convergence diagnostics.
The best method depends on the payoff and the question. A path-dependent exposure problem needs paths; a plain European calibration target often does not.
19. Verification ladder
- Moment test: fix one starting variance and compare simulated next-step mean/variance with the analytical CIR moments.
- Positivity test: verify every generated variance is non-negative without hidden clipping.
- Branch test: exercise both QE regimes with deterministic unit tests.
- Correlation test: verify simulated asset/variance innovation dependence.
- Martingale test: confirm the discounted forward-adjusted asset has no systematic drift.
- Vanilla benchmark: compare Monte Carlo prices with Heston characteristic-function prices.
- Time-step test: halve Δ repeatedly and measure bias convergence.
- Path-count test: verify Monte Carlo standard error scales approximately as 1/√N.
- Parameter-envelope test: repeat under difficult Feller-violating and high-vol-of-vol cases.
- Payoff test: include any discontinuous/path-dependent claims intended for production use.
20. Connections to the surrounding Bukit Timah Tutor knowledge estate
The calibration side is covered by Heston calibration algorithms. Calibration asks which parameters reproduce market prices; this article asks how to simulate paths once those parameters have been chosen.
The generic path engine is developed in Monte Carlo pricing algorithms. QE supplies a model-specific transition inside that larger Monte Carlo architecture.
For European benchmarks, Fourier COS option-pricing algorithms and Carr–Madan FFT pricing provide independent characteristic-function routes.
Low-discrepancy randomisation connects to Sobol quasi-Monte Carlo algorithms, but changing the point set does not repair a biased Heston transition. Discretisation bias and sampling error are separate weak links.
The complete lane is indexed at Finance & Banking Algorithms | Applied Mathematics in Real Financial Systems.
21. What would falsify confidence?
Confidence should be withdrawn if the simulator fails analytical one-step moment tests; produces material martingale drift; disagrees with trusted Heston prices beyond Monte Carlo error; does not converge under time-step refinement; changes materially under harmless implementation refactoring; fails in parameter regions actually used by calibration; or gives stable prices only while Greeks and path-sensitive outputs remain unstable.
22. Verification and update triggers
Preserve the Heston parameter set, rate/dividend curves, time grid, QE switch threshold, asset-step variant, random-number configuration, seed/scramble policy, path count, benchmark prices, martingale residual and convergence results for every model version.
Revalidate after changes to calibration bounds, QE branch logic, random-number libraries, time-grid construction, martingale correction, payoff library or hardware/vectorisation code. Trigger review when calibrated parameters move outside the previously tested envelope, when option-price residuals develop a pattern, when forward martingale error becomes significant, or when a new path-dependent product is added.
23. Primary and high-quality references
- Leif Andersen, Simple and Efficient Simulation of the Heston Stochastic Volatility Model, Journal of Computational Finance, 2008. The primary QE reference.
- Mark Broadie and Özgür Kaya, Exact Simulation of Stochastic Volatility and Other Affine Jump Diffusion Processes, Operations Research, 2006.
- Alexander van Haastrecht and Antoon Pelsser, Efficient, Almost Exact Simulation of the Heston Stochastic Volatility Model, University of Amsterdam repository.
- Steven Heston, A Closed-Form Solution for Options with Stochastic Volatility with Applications to Bond and Currency Options, Review of Financial Studies, 1993.
- For model validation principles, Federal Reserve Board and OCC, SR 11-7 — Guidance on Model Risk Management.
Educational boundary: QE is a numerical approximation to a chosen stochastic-volatility model. A simulation can be numerically excellent while the Heston model itself remains empirically inadequate for a particular market or payoff.

