Skip to content

Support domain inclusion in chained TrueMeasure transformations - #609

Open
Laasya-73 wants to merge 4 commits into
developfrom
feature/true-measure-domain-inclusion
Open

Support domain inclusion in chained TrueMeasure transformations#609
Laasya-73 wants to merge 4 commits into
developfrom
feature/true-measure-domain-inclusion

Conversation

@Laasya-73

Copy link
Copy Markdown
Collaborator

Summary

This PR generalizes compatibility checking for chained TrueMeasure transformations.

Previously, consecutive transformations were considered compatible only when the range of the preceding transformation exactly matched the domain of the next:

$$ [ R_{j-1} = D_j ] $$

This is more restrictive than necessary. The updated rule accepts the chain whenever the preceding range is contained within the next domain:

$$ [ R_{j-1} \subseteq D_j ] $$

This allows valid chained transformations with strict domain inclusion while continuing to reject genuinely incompatible ranges.

Changes

  • Add _range_in_domain() to AbstractTrueMeasure.
  • Replace exact domain/range equality checking with coordinate-wise containment.
  • Preserve NumPy broadcasting between (1, 2) and (d, 2) domain/range representations.
  • Support finite and unbounded interval bounds.
  • Update compatibility error messages to reflect containment semantics.
  • Add tests covering:
    • exact equality;
    • strict inclusion;
    • unbounded domains;
    • multidimensional inclusion;
    • broadcasting;
    • malformed/non-broadcastable bounds;
    • actual out-of-domain failures.
  • Add demos/true_measure_domain_inclusion.ipynb demonstrating:
    • the previous and updated compatibility behavior;
    • valid 1D and multidimensional TrueMeasure chains;
    • rejection of incompatible chains;
    • the distinction between domain compatibility, deterministic transport, and importance sampling;
    • the Gaussian/Logistic QMC example and the relationship between the importance-sampling likelihood ratio and the corresponding transport Jacobian.

Scope

This change is intentionally limited to domains/ranges represented as one-dimensional intervals or multidimensional axis-aligned boxes.

It does not introduce arbitrary measure-transport semantics, disconnected support representations, or changes to the existing importance-sampling implementation.

Notes

This PR replaces #602 after moving the feature branch into the QMCSoftware repository.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.71%. Comparing base (dc3d923) to head (c25697b).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #609      +/-   ##
===========================================
+ Coverage    88.65%   88.71%   +0.05%     
===========================================
  Files          104      104              
  Lines         8508     8530      +22     
===========================================
+ Hits          7543     7567      +24     
+ Misses         965      963       -2     
Flag Coverage Δ
alltests 88.71% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
qmcpy/true_measure/abstract_true_measure.py 94.65% <100.00%> (+2.91%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Generalizes chained TrueMeasure compatibility from exact range/domain equality to interval containment.

Changes:

  • Adds broadcast-aware range containment checks and revised errors.
  • Adds unit tests for valid and invalid chains.
  • Adds a detailed demonstration notebook.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
qmcpy/true_measure/abstract_true_measure.py Implements containment-based compatibility.
test/test_true_measures.py Tests containment and chaining behavior.
demos/true_measure_domain_inclusion.ipynb Demonstrates the new semantics and mathematical context.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +52 to +54
lower_bounds_valid = np.all(domain[:, 0] <= transform_range[:, 0])
upper_bounds_valid = np.all(transform_range[:, 1] <= domain[:, 1])
return bool(lower_bounds_valid and upper_bounds_valid)
Comment on lines +106 to +114
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"from matplotlib.patches import Rectangle\n",
"from scipy.stats import logistic, norm\n",
"\n",
"from qmcpy import DigitalNetB2, Kumaraswamy, Uniform\n",
"from qmcpy.true_measure.abstract_true_measure import AbstractTrueMeasure\n",
"from qmcpy.util import ParameterError\n",
@fjhickernell

Copy link
Copy Markdown
Member

@Laasya-73 you should add some examples in the demo notebook of integration with the chained measures.

Co-authored-by: fjhickernell <817530+fjhickernell@users.noreply.github.com>
@Laasya-73

Copy link
Copy Markdown
Collaborator Author

@Laasya-73 you should add some examples in the demo notebook of integration with the chained measures.

Sure, I will add and update the PR.

@sou-cheng-choi sou-cheng-choi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laasya-73

  1. Could you add the notebook to mkdocs.yml? Thank you.
  2. Validate input to _range_in_domain:
>>> AbstractTrueMeasure._range_in_domain(np.empty((0, 2)),[[0, 1]]) 
True
>>> AbstractTrueMeasure._range_in_domain([["a", "z"]], [["a", "z"]])
True
  1. In the notebook, from qmcpy import DigitalNetB2, Kumaraswamy, Uniform from qmcpy.true_measure.abstract_true_measure import AbstractTrueMeasure can be simplified to from qmcpy import AbstractTrueMeasure, DigitalNetB2, Kumaraswamy, Uniform

  2. In a command line window, you could run "make format" to beautify the files. Give it a try and see if it helps.

  3. For the notebook sub-section title, "### One compatibility visual", do you want to make it "D."? Sections 3 and 5 have sub-section labels. Would you like to make them consistent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants