Skip to content

Asset allocation and Simplex Transformation on LD Points - #634

Open
sou-cheng-choi wants to merge 424 commits into
developfrom
asset_allocation
Open

sou-cheng-choi wants to merge 424 commits into
developfrom
asset_allocation

Conversation

@sou-cheng-choi

@sou-cheng-choi sou-cheng-choi commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Issue: 561
  • Algorithmic or API impact:
    • Adds root, mirror, origami, and shift methods to qmcpy.discrete_distribution.simplex.SimplexTransform, implementing the cube-to-simplex transformations of Pillards & Cools (2005) / Pillards (2006).
    • demos/portfolio/portfolio_allocation_demo.ipynb: generalizes portfolio-weight generation from 4 sampler types to 8 -- IID/Lattice/Sobol/Halton, each also offered as a <sampler>_root variant.
    • No breaking API changes.
  • Commands run:
    • python -W ignore -m unittest test.test_dd_discrete_distribs.TestSimplexTransform -v

AI Assistance

  • No substantive AI assistance was used for this PR.

  • AI assistance substantively affected this PR, and I describe that use below.

  • Independent verification performed.

Checklist

  • I linked the relevant issue or explained why none was needed.
  • I added or updated tests, docs, notebooks, or explained why they were not needed.
  • I verified any equations, citations, benchmarks, numerical claims, or external references changed in this PR.
  • I reviewed AI-assisted content for licensing, provenance, attribution, confidentiality, and security concerns.
  • I described any CI, dependency, notebook runtime, or generated artifact changes if applicable.

@sou-cheng-choi sou-cheng-choi changed the title Asset allocation Asset allocation and Simplex Transformation on LD Points Sep 29, 2026
Comment thread test/booktests/tb_portfolio_allocation_demo.py Fixed

@alegresor alegresor 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.

quickly reviewed just parts in qmcpy/discrete_distribution/simplex/. Make sure to index like [...,i] instead of [:,i] to account for possible replications. Missing doctests in the QMCPy framework. Perhaps this should be a true measure SimplexUniform and implement these as transforms of LD points?

A class implementing various transformations from the unit cube to a simplex.

The simplex Ts is defined as:
Ts = {(x1, ..., xs) ∈ Rs : 0 ≤ x1 ≤ x2 ≤ ... ≤ xs ≤ 1}

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.

We use d instead of s.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed.

if points.ndim == 1:
points = points.reshape(1, -1)

mask = np.all(points[:, :-1] <= points[:, 1:], axis=1)

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.

should be points[...,:-1] <= points[...,1:] in case there are replications

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

if points.ndim == 1:
points = points.reshape(1, -1)

return np.sort(points, axis=1)

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.

np.sort(points,axis=-1) in case of replications

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines +137 to +139
y[:, d - 1] = points[:, d - 1] ** (1.0 / d)
for i in range(d - 2, -1, -1):
y[:, i] = y[:, i + 1] * points[:, i] ** (1.0 / (i + 1))

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.

index like [...,i] to account for replications

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed.

@sou-cheng-choi

Copy link
Copy Markdown
Member Author

@larissensium

Please review the code changes I've made today.

- derive normalized and Root weights from shared cube points
- compare each LD method with its matching IID baseline
- visualize IID and LD points before and after simplex mappings
- clarify figure interpretation and conclusions

@JiangruiKang JiangruiKang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The SimplexTransform tests and doctests pass, but I cannot approve the portfolio results yet. The 10- and 40-asset backtests apply weights in the return columns’ order to stocks in a different ticker order. The notebook acknowledges these mismatches, but still executes and displays the affected backtests. Please align the assets, rerun the notebook, and update the plots and conclusions.

The portfolio README calls the input CSVs versioned, while this PR tracks only the data README and generates CSVs from live Yahoo Finance downloads. Please correct that claim and provide stable data provenance sufficient to reproduce the reported numerical comparisons.

This branch has not been deployed

No deployments
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.

5 participants