Add analytical solutions, fast mean and variance calculations#50
Merged
ChrisRackauckas merged 1 commit intoFeb 12, 2026
Conversation
0832ed9 to
66573d8
Compare
Contributor
Author
Rebase and Documentation UpdateRebased onto current Conflict Resolution
Formatting
Documentation
Tests
Co-Authored-By: Chris Rackauckas accounts@chrisrackauckas.com |
66573d8 to
fbf30b5
Compare
…models This PR addresses issue SciML#2 by adding analytical solutions and fast moment calculation functions for the supported financial models: - GBM: gbm_mean, gbm_variance, gbm_std - Ornstein-Uhlenbeck: ou_mean, ou_variance, ou_std, ou_stationary_mean, ou_stationary_variance - CIR: cir_mean, cir_variance, cir_std, cir_stationary_mean, cir_stationary_variance - Black-Scholes log-price: bs_log_mean, bs_log_variance, bs_log_std - Heston: heston_mean, heston_variance_mean, heston_variance_variance These functions provide fast, exact analytical calculations without requiring Monte Carlo simulation, enabling significant performance improvements for applications that only need moment estimates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
fbf30b5 to
fd61687
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #2 by implementing analytical solutions, fast mean calculations, and fast variance calculations for the financial models in DiffEqFinancial.jl.
New Functions Added
Geometric Brownian Motion (GBM):
gbm_mean(μ, u0, t)- E[X(t)] = x₀ exp(μt)gbm_variance(μ, σ, u0, t)- Var[X(t)] = x₀² exp(2μt)(exp(σ²t) - 1)gbm_std(μ, σ, u0, t)- Standard deviationOrnstein-Uhlenbeck (OU):
ou_mean(a, r, u0, t)- E[X(t)] = r + (x₀ - r)exp(-at)ou_variance(a, σ, t)- Var[X(t)] = (σ²/2a)(1 - exp(-2at))ou_std(a, σ, t)- Standard deviationou_stationary_mean(r)- Long-run mean = rou_stationary_variance(a, σ)- Long-run variance = σ²/2aCox-Ingersoll-Ross (CIR):
cir_mean(κ, θ, u0, t)- E[r(t)] = θ + (r₀ - θ)exp(-κt)cir_variance(κ, θ, σ, u0, t)- Full CIR variance formulacir_std(κ, θ, σ, u0, t)- Standard deviationcir_stationary_mean(θ)- Long-run mean = θcir_stationary_variance(κ, θ, σ)- Long-run variance = θσ²/2κBlack-Scholes Log-Price:
bs_log_mean(r, σ, u0, t)- E[ln S(t)] = ln S₀ + (r - σ²/2)tbs_log_variance(σ, t)- Var[ln S(t)] = σ²tbs_log_std(σ, t)- Standard deviationHeston Model:
heston_mean(μ, u0, t)- E[S(t)] = S₀ exp(μt) (independent of volatility path)heston_variance_mean(κ, Θ, v0, t)- Mean of variance process (follows CIR)heston_variance_variance(κ, Θ, σ, v0, t)- Variance of variance processBenefits
Tests Added
Test plan
Closes #2
cc @ChrisRackauckas
🤖 Generated with Claude Code