Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
339 commits
Select commit Hold shift + click to select a range
78e9bb8
Increase readability and fix typos.
sou-cheng-choi Dec 7, 2025
6b36a7e
Add README. Add headers to examples.ipynb.
sou-cheng-choi Dec 7, 2025
1434f19
Update date. Fix a bug in plot_util.py
sou-cheng-choi Dec 7, 2025
0594ff4
Remove repeated lines
sou-cheng-choi Dec 7, 2025
0ad071c
Fix GBM documentation at http://127.0.0.1:8000/demos/GBM/gbm_demo/
sou-cheng-choi Dec 7, 2025
a7ba102
Update gbm_demo.ipynb
larissensium Dec 8, 2025
b72b3c7
fix typo and broken image of Fig 7 in gbm_demo's documentation
sou-cheng-choi Dec 8, 2025
381bdf2
deleted files
larissensium Dec 8, 2025
078cc78
Merge branch 'geometric_brownian_motion' of https://github.com/QMCSof…
larissensium Dec 8, 2025
61ed1d2
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Dec 8, 2025
8d7dfba
Update README and averaged_mae.py
sou-cheng-choi Dec 8, 2025
6dc8d1a
Update mkdocs.yml
sou-cheng-choi Dec 8, 2025
65ff300
Update mkdocs.yml
sou-cheng-choi Dec 8, 2025
27a253a
Fix typos
sou-cheng-choi Dec 8, 2025
2fa9711
Change to develop branch for Colab button
sou-cheng-choi Dec 8, 2025
9b4f921
Update date
sou-cheng-choi Dec 8, 2025
1f87f9b
Update examples.ipynb
larissensium Dec 8, 2025
f0fd5ac
Merge branch 'geometric_brownian_motion' of https://github.com/QMCSof…
larissensium Dec 8, 2025
f1cd33b
Update averaged_mae.py
larissensium Dec 8, 2025
9553816
Address copilot review comments
sou-cheng-choi Dec 8, 2025
3540c03
Match parent class's method signature
sou-cheng-choi Dec 8, 2025
a84eab0
Remove unnecessary space
sou-cheng-choi Dec 8, 2025
d4cb944
Update GBM demo
sou-cheng-choi Dec 8, 2025
25f5fc4
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Dec 8, 2025
8af65aa
updated plots
larissensium Dec 8, 2025
929be17
fix typos + update examples notebook
larissensium Dec 8, 2025
ec807b2
Fix typos. Git rm .png. Add testbook. Rename examples notebook.
sou-cheng-choi Dec 9, 2025
57560ae
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Dec 9, 2025
64db53b
+doc strings. -test file and examples notebook.
sou-cheng-choi Dec 9, 2025
0b1e951
Update averaged_mae.py
larissensium Dec 9, 2025
3c699bc
Merge branch 'geometric_brownian_motion' of https://github.com/QMCSof…
larissensium Dec 9, 2025
e2ed4b1
final updates
larissensium Dec 9, 2025
4b48a3b
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Dec 11, 2025
ce3a428
Create gbm_todo
larissensium Dec 11, 2025
94a2500
Add TODO
sou-cheng-choi Dec 12, 2025
9a404c4
+1 item
sou-cheng-choi Dec 13, 2025
e895169
Make sure booktests.yml failed if failures occurred.
sou-cheng-choi Dec 13, 2025
e78bff5
Fix booktests failures
sou-cheng-choi Dec 13, 2025
d449f48
Merge branch 'develop' into booktests_choi
sou-cheng-choi Dec 13, 2025
5060083
Display actual Python exceptions in parsl_test_runner CI logs (#437)
Copilot Dec 13, 2025
cdb3974
Add .md as file extension to TODO file. DONE some items in there.
sou-cheng-choi Dec 14, 2025
94906b0
Fix testbook failures
sou-cheng-choi Dec 14, 2025
83a67fe
Fix testbook failures
sou-cheng-choi Dec 14, 2025
ba9ca28
Fix remote CI failure in tb_linear_scrambled_halton.py
sou-cheng-choi Dec 14, 2025
02ee321
Renamed demos/GBM/code/ to gbm_code. Update README.
sou-cheng-choi Dec 14, 2025
4977472
unified plotting function
larissensium Dec 14, 2025
3880ef1
Add demos/GBM to sys.path
sou-cheng-choi Dec 14, 2025
18a68a9
Fixing broken tests
sou-cheng-choi Dec 15, 2025
3fdd684
Turn on execute=True
sou-cheng-choi Dec 15, 2025
1065842
Add quantlib
sou-cheng-choi Dec 15, 2025
bee80ed
+ ipywidgets
sou-cheng-choi Dec 15, 2025
8780327
Use helper functions
sou-cheng-choi Dec 15, 2025
ed2aa0e
Shorten testbook runtime by injecting is_debug=True
sou-cheng-choi Dec 15, 2025
da3ff28
Update tb_gbm_examples.py
sou-cheng-choi Dec 15, 2025
9186d4a
Increase timeout. Add nbconvert.
sou-cheng-choi Dec 15, 2025
55566bd
Workaround for now
sou-cheng-choi Dec 15, 2025
2f9c2ab
Merge remote-tracking branch 'origin/booktests_choi' into geometric_b…
larissensium Dec 16, 2025
755e81d
Update gbm to-do list
larissensium Dec 16, 2025
813605d
Shorten run time of tb_joss.py
sou-cheng-choi Dec 17, 2025
b57da24
Address PR review comments: fix typo, remove unused imports, clarify …
Copilot Dec 17, 2025
7a76f6c
Fix a bug and speedup tb_jboss2025
sou-cheng-choi Dec 18, 2025
2c1a5f4
Fix paths
sou-cheng-choi Dec 18, 2025
8ef2513
Add seed for reproducible results
sou-cheng-choi Dec 18, 2025
6320563
Add seed value and fix path.
sou-cheng-choi Dec 18, 2025
ada7b74
Speed up tests. Add README.
sou-cheng-choi Dec 18, 2025
c5f0526
Add alltests,yml
sou-cheng-choi Dec 18, 2025
a91c98c
Update alltests.yml
sou-cheng-choi Dec 18, 2025
16fece9
Install pytest-xdist
sou-cheng-choi Dec 18, 2025
e9bcc18
Update alltests.yml
sou-cheng-choi Dec 18, 2025
66d73e2
Update alltests.yml
sou-cheng-choi Dec 18, 2025
1e8692a
Update alltests.yml
sou-cheng-choi Dec 18, 2025
3cb166e
Fix path
sou-cheng-choi Dec 18, 2025
1ac3df1
Update alltests.yml
sou-cheng-choi Dec 18, 2025
638ec82
Update all tests
sou-cheng-choi Dec 18, 2025
63d1502
Install LaTeX on Windows
sou-cheng-choi Dec 18, 2025
a32bec3
Fix Windows LaTeX
sou-cheng-choi Dec 19, 2025
bd2a8d3
Update alltests.yml
sou-cheng-choi Dec 19, 2025
09199d4
Fix latex on windows
sou-cheng-choi Dec 19, 2025
8651951
One more attempt to fix Windows booktest error
sou-cheng-choi Dec 19, 2025
336a23f
Update alltests.yml
sou-cheng-choi Dec 20, 2025
0a9dfe8
Fix latex issues on WIndows
sou-cheng-choi Dec 20, 2025
e07d070
Fix windows latex
sou-cheng-choi Dec 20, 2025
b61b643
Update alltests.yml
sou-cheng-choi Dec 20, 2025
1b33600
Update alltests.yml
sou-cheng-choi Dec 20, 2025
2df2d00
Take out ghostcript installation to save time
sou-cheng-choi Dec 20, 2025
a5cf3ce
All tests
sou-cheng-choi Dec 20, 2025
5e394dc
Update alltests.yml
sou-cheng-choi Dec 20, 2025
306f0eb
Fix typo
sou-cheng-choi Dec 20, 2025
be93869
Update alltests.yml
sou-cheng-choi Dec 20, 2025
20b1e6e
Update alltests.yml
sou-cheng-choi Dec 20, 2025
b4c5732
Add documentation. Remove duplicate statements.
sou-cheng-choi Dec 20, 2025
a2e940e
Fix windows add swap space
sou-cheng-choi Dec 20, 2025
07a73da
+Windows swap space
sou-cheng-choi Dec 20, 2025
6e2215a
Best effort pagefile
sou-cheng-choi Dec 20, 2025
36f2730
Last try on windows pagefile
sou-cheng-choi Dec 20, 2025
7fef80a
Speed up tb_elliptic_pde.py. Suppress matplotlib outputs in Jupyter N…
sou-cheng-choi Dec 20, 2025
ac2e478
Update tb_elliptic_pde.py
sou-cheng-choi Dec 20, 2025
a34b097
Speed up a bit
sou-cheng-choi Dec 21, 2025
9f54b9b
Skip unnecessary installation for Windows
sou-cheng-choi Dec 21, 2025
66c07fd
Speedup windows booktests
sou-cheng-choi Dec 21, 2025
e22cc36
More caching. Pytest-xdist for all OS.
sou-cheng-choi Dec 21, 2025
47104f1
Comment out redundant statements
sou-cheng-choi Dec 21, 2025
d47356a
Update alltests.yml
sou-cheng-choi Dec 21, 2025
fb52374
Update alltests.yml
sou-cheng-choi Dec 21, 2025
a4842c4
Dynamically detect number of processors (workers)
sou-cheng-choi Dec 21, 2025
953e56f
Revert and use 4 processors for WIndows Booktests
sou-cheng-choi Dec 21, 2025
abbfe6a
Resolve reviews of copilot
sou-cheng-choi Dec 21, 2025
ebf0466
Disable two workflows
sou-cheng-choi Dec 21, 2025
a71b141
Update alltests.yml
sou-cheng-choi Dec 21, 2025
fb546f9
Delay LaTeX Installations
sou-cheng-choi Dec 21, 2025
ab77cec
Fix LaTeX error involving geometry.sty not found
sou-cheng-choi Dec 21, 2025
200179e
Install LaTeX after Python dependencies
sou-cheng-choi Dec 22, 2025
abc116a
Update __init__.py
sou-cheng-choi Dec 22, 2025
278b3e7
Fix windows LaTeX failures
sou-cheng-choi Dec 23, 2025
6243620
Merge branch 'develop' into booktests_choi
sou-cheng-choi Dec 23, 2025
00b089b
Take out redundant line
sou-cheng-choi Dec 23, 2025
5c1d861
Introduce debug mode. Delay LaTeX installation.
sou-cheng-choi Dec 23, 2025
e8b6256
Add memory
sou-cheng-choi Dec 23, 2025
fbebaad
Clear cache to free space
sou-cheng-choi Dec 23, 2025
edb503e
Combine coverage reports
sou-cheng-choi Dec 23, 2025
0ad8a0e
Get one final coverage report
sou-cheng-choi Dec 23, 2025
89c929a
Correctly remove .coverage on windows
sou-cheng-choi Dec 23, 2025
5779501
Update README on coverage and also commments
sou-cheng-choi Dec 23, 2025
cc68815
Clear space
sou-cheng-choi Dec 23, 2025
9a4fc71
Append coverage for Parsl BookTests. Update README.
sou-cheng-choi Dec 23, 2025
f37d0e0
Display coverage report
sou-cheng-choi Dec 23, 2025
5336600
Simplify README. Fix combine coverage job
sou-cheng-choi Dec 23, 2025
8e678bc
More robut MikTex installation on Windows
sou-cheng-choi Dec 23, 2025
a85f890
Fix coverage issue
sou-cheng-choi Dec 24, 2025
f2db76f
Update coverage combination
sou-cheng-choi Dec 24, 2025
9b37bdd
Standardize test seeds to 7 and add trailing commas (#446)
Copilot Dec 24, 2025
1068b2a
Find coverage files before combining
sou-cheng-choi Dec 24, 2025
434c28e
Merge branch 'booktests_choi' of https://github.com/QMCSoftware/QMCSo…
sou-cheng-choi Dec 24, 2025
22bcf8c
fix failure of coverage combined report
sou-cheng-choi Dec 24, 2025
6b8d04c
Update alltests.yml
sou-cheng-choi Dec 25, 2025
f0227f3
Fix coverage reports
sou-cheng-choi Dec 25, 2025
4310545
Fix coverage file detection to exclude .coveragerc
sou-cheng-choi Dec 25, 2025
80de9cb
Fix coverage file detection in alltests.yml line 371
sou-cheng-choi Dec 25, 2025
2826185
Update alltests.yml
sou-cheng-choi Dec 25, 2025
a3f565f
Revert and fix
sou-cheng-choi Dec 25, 2025
e6c75af
Remove combining report
sou-cheng-choi Dec 25, 2025
8c84e9a
Summarize OS vs coverage
sou-cheng-choi Dec 25, 2025
f555b8b
Coverage reports for each OS
sou-cheng-choi Dec 25, 2025
d7729bc
Display final reports for Mac and Linux
sou-cheng-choi Dec 25, 2025
637a506
Merge branch 'develop' into booktests_choi
sou-cheng-choi Dec 26, 2025
3a1cdce
Update README.md
sou-cheng-choi Dec 26, 2025
a5fdcfb
Merge branch 'booktests_choi' of https://github.com/QMCSoftware/QMCSo…
sou-cheng-choi Dec 26, 2025
4728a92
+Code coverage badge
sou-cheng-choi Dec 26, 2025
e0a71dd
Remove coverage reports in CI
sou-cheng-choi Dec 26, 2025
bbec8f5
Speedup
sou-cheng-choi Dec 26, 2025
d502201
Remove and ignore coverage files. Update README.
sou-cheng-choi Dec 26, 2025
aaf4015
Skip slow notebook tests on windows
sou-cheng-choi Dec 27, 2025
b4b8916
import pytest
sou-cheng-choi Dec 27, 2025
5320a9b
Add seed values for reproducible test results
sou-cheng-choi Dec 27, 2025
b6a9e6f
Add seed value
sou-cheng-choi Dec 27, 2025
7bc34ae
Mark 1 more slow test
sou-cheng-choi Dec 27, 2025
6f4cf4c
Add two targets in Makefile for reuse in alltests.yml.
sou-cheng-choi Dec 27, 2025
a0ab494
Revert "Add two targets in Makefile for reuse in alltests.yml."
sou-cheng-choi Dec 27, 2025
3213ed1
Remove duplicate target in makefile
sou-cheng-choi Dec 28, 2025
ba32723
Remove useless import
sou-cheng-choi Dec 28, 2025
d2edf63
Merge branch 'develop' into booktests_choi
sou-cheng-choi Dec 28, 2025
b85707a
Increase coverage to 100% for qmcpy codebase
sou-cheng-choi Dec 28, 2025
1c1eed3
Initial plan (#449)
Copilot Dec 28, 2025
5740bd4
Remove extra spaces
sou-cheng-choi Dec 28, 2025
ee85ebb
Merge branch 'booktests_choi' of https://github.com/QMCSoftware/QMCSo…
sou-cheng-choi Dec 28, 2025
f877181
Removed useless import
sou-cheng-choi Dec 28, 2025
ab4c4b6
removed useless import
sou-cheng-choi Dec 28, 2025
5be17c9
Add testing documentation for developers
sou-cheng-choi Dec 28, 2025
6e706fd
Enhance code and doc readability
sou-cheng-choi Dec 30, 2025
98a7213
Add tests documentation for developers
sou-cheng-choi Dec 30, 2025
25ec48e
Update .gitignore
sou-cheng-choi Dec 30, 2025
b7326ef
Merge branch 'develop' into booktests_choi
sou-cheng-choi Dec 31, 2025
c626b62
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Dec 31, 2025
f58202e
Fix tests
sou-cheng-choi Dec 31, 2025
c46e098
Update tb_gbm_demo.py
sou-cheng-choi Dec 31, 2025
7ceadb4
Add comments to makefile
sou-cheng-choi Jan 1, 2026
28e144f
Speedup time consuming tests
sou-cheng-choi Jan 1, 2026
26c28d9
Remove a redundant function. Change notebook in memory or on disk.
sou-cheng-choi Jan 2, 2026
33a124d
Install Windows MikTex with retry
sou-cheng-choi Jan 2, 2026
53868a5
Update alltests.yml
sou-cheng-choi Jan 2, 2026
56207e5
Add -y flag
sou-cheng-choi Jan 2, 2026
c4f3e46
Speed up test/booktests/tb_asian_option_mlqmc.py
sou-cheng-choi Jan 2, 2026
d306bc7
Speed up
sou-cheng-choi Jan 2, 2026
32e9b85
speedup tb_iris
sou-cheng-choi Jan 2, 2026
081a9e2
Update iris.ipynb
sou-cheng-choi Jan 2, 2026
473527e
Speedup tb_vectorized_qmc_bayes.py
sou-cheng-choi Jan 2, 2026
a385533
Speedup test/booktests/tb_gaussian_diagnostics_demo.py
sou-cheng-choi Jan 2, 2026
d90fea4
Speedup tb_ray_tracing.py
sou-cheng-choi Jan 2, 2026
3bd5f19
Speedup tb_vectorized_qmc
sou-cheng-choi Jan 2, 2026
6a31fdc
Speedup test/booktests/tb_qei_demo_for_blog.py
sou-cheng-choi Jan 2, 2026
6c84e46
Update tb_digital_net_b2.py
sou-cheng-choi Jan 2, 2026
8e4ef5d
Update kernel name and python version
sou-cheng-choi Jan 2, 2026
54bccc5
Update alltests.yml
sou-cheng-choi Jan 2, 2026
e01d723
Apply PR review feedback: fix whitespace and simplify parameter passi…
Copilot Jan 2, 2026
49ef2bb
Merge branch 'booktests_choi' into geometric_brownian_motion
sou-cheng-choi Jan 2, 2026
bbc747d
Speed up tb_gbm_demo
sou-cheng-choi Jan 2, 2026
88dfcac
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Jan 2, 2026
7a989bb
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Jan 3, 2026
26eb3c2
Delete tb_plot_proj_function.py
sou-cheng-choi Jan 3, 2026
d678d28
Create tb_plot_proj_function.py
sou-cheng-choi Jan 3, 2026
95ce4d0
Delete tb_portfolio_allocation_demo.py
sou-cheng-choi Jan 3, 2026
490ba89
Update tb_gbm_demo.py
sou-cheng-choi Jan 3, 2026
34e0ac3
Add skip and stop patterns
sou-cheng-choi Jan 3, 2026
55be655
Update __init__.py
sou-cheng-choi Jan 3, 2026
1586ba9
Update gbm_todo.md
sou-cheng-choi Jan 3, 2026
4567d75
averaged results for fig_6
larissensium Jan 12, 2026
5fed5bc
Update gbm_demo.ipynb
larissensium Jan 14, 2026
d1074dd
Merge branch 'develop' into geometric_brownian_motion
larissensium Jan 15, 2026
e618134
fix
larissensium Jan 15, 2026
b906300
Update demos/GBM/gbm_code/data_util.py
sou-cheng-choi Jan 15, 2026
bac1676
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Jan 15, 2026
f42892f
Fix test failures
sou-cheng-choi Jan 15, 2026
901d99d
PEP8
sou-cheng-choi Jan 15, 2026
8f5884a
Update tb_gbm_demo.py
sou-cheng-choi Jan 15, 2026
477be99
Speed up test/booktests/tb_gbm_demo.py
sou-cheng-choi Jan 15, 2026
ab517c2
Removed commented function
sou-cheng-choi Jan 15, 2026
dbaf207
Add docstrings to add_quantlib_results and add_qmcpy_results
sou-cheng-choi Jan 15, 2026
3da3eb8
Render math in GBM docstrings: wrap E[S_T] and S_T with $...$
sou-cheng-choi Jan 15, 2026
2788012
Minor changes
sou-cheng-choi Jan 15, 2026
4b295ab
Remove '#' from stop_at_pattern in test file
sou-cheng-choi Jan 15, 2026
40b8829
Normalize cell source to a single string
sou-cheng-choi Jan 15, 2026
62a1cd2
fix issue with averaged std error
larissensium Jul 25, 2026
c60cafc
Update gbm_demo.ipynb
larissensium Jul 25, 2026
9891c30
pull develop into gbm
larissensium Aug 8, 2026
af850b3
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Aug 9, 2026
58e523e
Fix method name for symlink
sou-cheng-choi Aug 9, 2026
b73e3b6
add unit tests for new demos
sou-cheng-choi Aug 9, 2026
3d0c9ac
remove obsolete NotebookTests
sou-cheng-choi Aug 9, 2026
68904df
update README to correct example testbook filename
sou-cheng-choi Aug 9, 2026
83cb523
Restore test files from develop branch
sou-cheng-choi Aug 9, 2026
1dc3c1e
Updated reproducibility header by bumping package versions.
sou-cheng-choi Aug 9, 2026
0176084
Refactor notebook tests from develop branch
sou-cheng-choi Aug 9, 2026
714eb6a
Scope branch to demos/GBM only: reset all other files to develop
sou-cheng-choi Aug 9, 2026
8022323
Add documentation and remove trailing spaces
sou-cheng-choi Aug 9, 2026
059316e
Added formulas
larissensium Aug 10, 2026
2942ecc
Update gbm_demo.ipynb
larissensium Aug 11, 2026
56cf38d
edit notation for theoretical mean and std dev
larissensium Aug 11, 2026
88a47e3
Update gbm_demo.ipynb
larissensium Aug 11, 2026
4cd7805
updated computation of std dev error
larissensium Aug 12, 2026
55c879c
pull changes from develop
larissensium Aug 12, 2026
376944e
fix documentation
larissensium Aug 12, 2026
1713487
Potential fix for pull request finding 'Unused local variable'
larissensium Aug 13, 2026
11b51f2
fix typos
sou-cheng-choi Aug 14, 2026
c55706e
Merge branch 'develop' into geometric_brownian_motion
sou-cheng-choi Aug 14, 2026
689b38f
Remove trailing spaces
sou-cheng-choi Aug 14, 2026
772f798
Fix same QuantLib paths with different seed values. Add unit tests.
sou-cheng-choi Aug 14, 2026
8e5e28a
Speed up
sou-cheng-choi Aug 14, 2026
21d8010
Update notebooks
sou-cheng-choi Aug 14, 2026
72e7b9e
Correct speedup based on the same sampler from both packages
sou-cheng-choi Aug 14, 2026
b003f52
Update demo
sou-cheng-choi Aug 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 55 additions & 19 deletions demos/GBM/gbm_code/data_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import numpy as np
import numpy.typing as npt
import pandas as pd
import quantlib_util as qlu
import qmcpy_util as qpu
import config as cf

if __package__: # Imported as demos.GBM.gbm_code.data_util (e.g. by pytest)
from . import config as cf
from . import qmcpy_util as qpu
from . import quantlib_util as qlu
else: # Compatibility symlink imported with demos/GBM on sys.path.
import config as cf
import qmcpy_util as qpu
import quantlib_util as qlu

# Speedups are only reported between runs that share a sampler, so the column
# name states that explicitly; see create_timing_dataframe().
SPEEDUP_COLUMN = "Speedup (same sampler)"


def add_theoretical_results(
Expand Down Expand Up @@ -35,6 +45,7 @@ def add_quantlib_results(
quantlib_final: npt.NDArray[np.floating], # per replication mean
theoretical_mean: float,
theoretical_std: float,
ql_stds: npt.NDArray[np.floating] # per replication std dev
) -> None:
"""
Add summary statistics for QuantLib simulations based on per-replication means.
Expand All @@ -49,19 +60,23 @@ def add_quantlib_results(
quantlib_final: 1D array of per-replication sample means of $S_T$.
theoretical_mean: Theoretical expected value $E[S_T]$ used as a benchmark.
theoretical_std: Theoretical standard deviation of $S_T$ used as a benchmark.
ql_stds: 1D array of per-replication standard deviations of $S_T$.
"""
ql_emp_mean = np.mean(quantlib_final)
ql_emp_std = np.std(quantlib_final, ddof=1)
ql_emp_std_avg = np.mean(ql_stds)

ql_mae = np.mean(np.abs(quantlib_final - theoretical_mean))
ql_sde = np.mean(np.abs(ql_stds - theoretical_std))


results_data.append(
{
"Method": "QuantLib",
"Sampler": sampler_type,
"Mean": ql_emp_mean,
"Std Dev": ql_emp_std,
"Std Dev": ql_emp_std_avg,
"Mean Absolute Error": ql_mae,
"Std Dev Error": abs(ql_emp_std - theoretical_std),
"Std Dev Error": ql_sde,
}
)

Expand All @@ -73,6 +88,7 @@ def add_qmcpy_results(
qp_emp_mean: float,
theoretical_mean: float,
theoretical_std: float,
qp_stds: npt.NDArray[np.floating] # per replication std dev
) -> None:
"""
Add empirical QMCPy results, computed from per-replication means, to results data.
Expand All @@ -89,18 +105,21 @@ def add_qmcpy_results(
qp_emp_mean: Overall empirical mean across all replications.
theoretical_mean: Theoretical expected value used as a benchmark.
theoretical_std: Theoretical standard deviation used as a benchmark.
qp_stds: 1D array of per-replication standard deviations of $S_T$.
"""
qp_emp_std = np.std(qmcpy_final, ddof=1)
qp_mae = np.mean(np.abs(qmcpy_final - theoretical_mean))

qp_emp_std_avg = np.mean(qp_stds)
qp_sde = np.mean(np.abs(qp_stds - theoretical_std))

results_data.append(
{
"Method": "QMCPy",
"Sampler": sampler_type,
"Mean": qp_emp_mean,
"Std Dev": qp_emp_std,
"Std Dev": qp_emp_std_avg,
"Mean Absolute Error": qp_mae,
"Std Dev Error": abs(qp_emp_std - theoretical_std),
"Std Dev Error": qp_sde,
}
)

Expand Down Expand Up @@ -137,23 +156,30 @@ def process_sampler_data(

if sampler_type in ["IIDStdUniform", "Sobol"]:
ql_means = np.empty(replications)
ql_stds = np.empty(replications)
ql_seed = params_ql["seed"]

for r in range(replications):
params_ql["seed"] = ql_seed + r
quantlib_paths, ql_gbm = qlu.generate_quantlib_paths(**params_ql)
ql_means[r] = quantlib_paths[:, -1].mean()
ql_stds[r] = quantlib_paths[:, -1].std(ddof=1)

params_ql["seed"] = ql_seed


else:
ql_means = None

qmcpy_paths, qp_gbm = qpu.generate_qmcpy_paths(**params_qp)

if qmcpy_paths.ndim == 3:
qp_means = qmcpy_paths[:, :, -1].mean(axis=1)
qp_stds = qmcpy_paths[:, :, -1].std(axis=1, ddof=1)
else:
qp_means = np.array([qmcpy_paths[:, -1].mean()])
qp_stds = np.array([qmcpy_paths[:, -1].std(ddof=1)])


if ql_means is not None:
add_quantlib_results(
Expand All @@ -162,6 +188,7 @@ def process_sampler_data(
ql_means,
theoretical_mean,
theoretical_std,
ql_stds
)

add_qmcpy_results(
Expand All @@ -171,24 +198,29 @@ def process_sampler_data(
qp_means.mean(),
theoretical_mean,
theoretical_std,
qp_stds
)

return quantlib_paths, qmcpy_paths, ql_gbm, qp_gbm, params_ql, params_qp


def create_timing_dataframe(
quantlib_results: dict, qmcpy_results: dict, baseline_sampler: str
quantlib_results: dict, qmcpy_results: dict
) -> pd.DataFrame:
"""
Create comprehensive timing comparison table from benchmark results.

The speedup of a QMCPy row is computed against the QuantLib run that uses
the *same* sampler, so the ratio is like-for-like. Samplers that QuantLib
is not benchmarked with here (e.g. Lattice, Halton) have no counterpart and
report "-" rather than a ratio against an unrelated QuantLib run.

Args:
quantlib_results: Dictionary mapping sampler names to timing results
qmcpy_results: Dictionary mapping sampler names to timing results
baseline_sampler: Sampler to use as baseline for speedup calculation

Returns:
DataFrame with timing statistics and speedup comparisons
DataFrame with timing statistics and same-sampler speedup comparisons
"""
timing_data = []

Expand All @@ -200,21 +232,25 @@ def create_timing_dataframe(
"Sampler": sampler_type,
"Mean Time (s)": result["average"],
"Std Dev (s)": result["stdev"],
"Speedup": "-",
SPEEDUP_COLUMN: "-",
}
)

# Add QMCPy data with speedup calculation
baseline_time = quantlib_results[baseline_sampler]["average"]
# Add QMCPy data with same-sampler speedup calculation
for sampler_type, result in qmcpy_results.items():
speedup = baseline_time / result["average"]
quantlib_result = quantlib_results.get(sampler_type)
speedup = (
quantlib_result["average"] / result["average"]
if quantlib_result is not None
else "-"
)
timing_data.append(
{
"Method": "QMCPy",
"Sampler": sampler_type,
"Mean Time (s)": result["average"],
"Std Dev (s)": result["stdev"],
"Speedup": speedup,
SPEEDUP_COLUMN: speedup,
}
)

Expand Down Expand Up @@ -244,7 +280,7 @@ def extract_comparison_data(results_df: pd.DataFrame) -> tuple:
else None
)

# Get QuantLib data (only available for some samplers
# Get QuantLib data (only available for some samplers)
ql_error_dict = dict(
zip(quantlib_data["Sampler"], quantlib_data["Mean Absolute Error"])
)
Expand Down Expand Up @@ -359,7 +395,7 @@ def collect_library_results(
# QMCPy results
try:
qp_paths, _ = qpu.generate_qmcpy_paths(sampler_type=sampler, **qp_params)
qp_final = qp_paths[:, -1]
qp_final = qp_paths[..., -1]
qp_mean = np.mean(qp_final)
qp_std = np.std(qp_final, ddof=1)

Expand Down
2 changes: 1 addition & 1 deletion demos/GBM/gbm_code/latex_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate_latex_table(df: pd.DataFrame, caption: str, label: str) -> str:
header = (
"Method & Sampler & Mean & Std Dev & Mean Absolute & Std Dev & "
"Mean Time (s) & Std Dev (s) & Speedup \\\\\n & & & & "
"Error & Error & & & \\\\"
"Error & Error & & & (same sampler) \\\\"
)

latex_table = df.style.hide(axis="index").to_latex(
Expand Down
Loading
Loading