Repository navigation
Port the legacy GBM script and add its regression test - #13
Merged
Merged
Conversation
rk-mlu
force-pushed
the
m1-port-gbm-script
branch
2 times, most recently
from
November 2, 2026 10:03
75150ee to
6a24501
Compare
8 tasks done
rk-mlu
force-pushed
the
m1-port-gbm-script
branch
4 times, most recently
from
November 3, 2026 17:41
af478cb to
d3193b5
Compare
- tests/regression/data/legacy_gbm_em_l2error.npz: errors of the unmodified legacy function num_exp_GBM.compute_L2_errors (Euler–Maruyama only, 2000 paths, N = 10 * 2**k for k < 6, seed 20250718), with parameters and the SHA-256 checksums of the three script files. - tests/regression/test_legacy_gbm.py rebuilds the legacy Brownian paths, wraps them as BrownianPath and reproduces the errors (bitwise on the generating machine, rtol 1e-12 in the test). - examples/strong_error_gbm.py ports the experiment with the library's coupling (one finest path, coarsened) and prints errors, EOCs and 95 % confidence intervals; a smoke test runs it with small parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018KaTyMUfivRVAGYQR6kGnp
rk-mlu
force-pushed
the
m1-port-gbm-script
branch
from
November 4, 2026 10:03
d3193b5 to
f5d1154
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.
First legacy port of milestone M1, stacked on #12 (base
m1-end-to-end-slice; GitHub retargets it tomainonce #12 is merged). It satisfies the milestone gate "at least one legacy script is ported onto the new features".What is added
tests/regression/data/legacy_gbm_em_l2error.npznum_exp_GBM.compute_L2_errors, Euler–Maruyama only, with seed, parameters, NumPy version and SHA-256 checksums ofnum_exp_GBM.py,StochODEs.py,SODESolvers.pytests/regression/data/README.mdtests/regression/test_legacy_gbm.pyBrownianPath, and requires the library to reproduce the legacy errorsexamples/strong_error_gbm.pytests/unit/test_examples.pyReference data
The legacy script draws all step sizes from one generator
default_rng(20250718), increments of shape(n_paths, m, n). These are other random numbers thanWienerProcess.sample_pathdraws for the same seed, so the test rebuilds the legacy paths (the convention is documented in the test module). The legacyL2_error()is exactly the library's default strong error, uniformly on the grid with p = 2.To keep the test fast, the data use 2000 paths and N = 10·2^k for k = 0, …, 5 instead of 50 000 paths and k ≤ 7. On the generating machine the library reproduces all six errors bitwise; the test uses
rtol = 1e-12becauseexpmay round differently on other platforms.Example vs. legacy at full size (50 000 paths)
Two independent Monte Carlo estimates; the differences are within their combined error (at N = 20 and 80 slightly outside the interval of the single estimate, as expected when comparing two estimates with heavy-tailed pathwise errors). The example needs about 3 GB with the book's parameters;
--n-pathsreduces that.Not ported here
StrConvGBM.py(Python 2, unseeded) is superseded bynum_exp_GBM.py. The Milstein part ofnum_exp_GBM.pyandGBM_Milstein_L2error.pyfollow in M2;GBM_STM_*andGBM_BDF2_*with the implicit schemes in phase 2.Checks
Fast suite 309 passed with PyTorch, 296 without; coverage 100 %; Ruff, mypy, codespell and Sphinx
-Wpass.Generated by Claude Code