Skip to content

black_litterman: fix broken decolletage cells and revise the lecture - #403

Merged
mmcky merged 1 commit into
mainfrom
nov_penn3
Nov 4, 2026
Merged

mmcky merged 1 commit into
mainfrom
nov_penn3

Conversation

@mmcky

@mmcky mmcky commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Fix the two decolletage cells that fail under NumPy 2 (TypeError: only 0-dimensional arrays can be converted to Python scalars), which passed length-1 arrays to matplotlib as text and marker coordinates.

Revise the lecture:

  • Redesign the simulated example (one-factor market, monthly Sharpe ratio 0.12, T = 120, true means close to the market-implied ones), so that extreme estimated portfolios come from estimation error rather than from the true parameters. The old example's true optimum was itself extreme, so shrinking toward the market made things worse.
  • Add sections on views about a few assets (He-Litterman P, Q, Omega), on whether shrinkage pays (Monte Carlo certainty-equivalent losses), and on robustness about the mean, including its Bayesian reading as shrinkage toward zero along an information contract curve.
  • Refactor the decolletage figures into one function with distinct colors and a legend; show Black-Litterman mixtures for three taus.
  • Appendix: define B as a ratio of limits, normalize the relative-MSE figure by its IID value, use "sampling interval" consistently, and move Merton's fixed-span experiment into the text.
  • Update Exercises 1-3, add figure captions, and fix wording, notation and citation style.
  • Add bib entries HeLitterman1999, GarlappiUppalWang2007, and DeMiguelGarlappiUppal2009.

Fix the two decolletage cells that fail under NumPy 2 (TypeError: only
0-dimensional arrays can be converted to Python scalars), which passed
length-1 arrays to matplotlib as text and marker coordinates.

Revise the lecture:

- Redesign the simulated example (one-factor market, monthly Sharpe
  ratio 0.12, T = 120, true means close to the market-implied ones), so
  that extreme estimated portfolios come from estimation error rather
  than from the true parameters. The old example's true optimum was
  itself extreme, so shrinking toward the market made things worse.
- Add sections on views about a few assets (He-Litterman P, Q, Omega),
  on whether shrinkage pays (Monte Carlo certainty-equivalent losses),
  and on robustness about the mean, including its Bayesian reading as
  shrinkage toward zero along an information contract curve.
- Refactor the decolletage figures into one function with distinct
  colors and a legend; show Black-Litterman mixtures for three taus.
- Appendix: define B as a ratio of limits, normalize the relative-MSE
  figure by its IID value, use "sampling interval" consistently, and
  move Merton's fixed-span experiment into the text.
- Update Exercises 1-3, add figure captions, and fix wording, notation
  and citation style.
- Add bib entries HeLitterman1999, GarlappiUppalWang2007, and
  DeMiguelGarlappiUppal2009.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 22:20
@netlify

netlify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lustrous-melomakarona-3ee73e ready!

Name Link
🔨 Latest commit 771d2a0
🔍 Latest deploy log https://app.netlify.com/projects/lustrous-melomakarona-3ee73e/deploys/6aebafa2f76d0d3816c40d60
😎 Deploy Preview https://deploy-preview-403--lustrous-melomakarona-3ee73e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🟡 Changes recommended

A moderate active issue remains because the Black-Litterman lecture uses an explicit matrix inverse (np.linalg.inv) at line 389, which can be numerically unstable compared to solving a linear system for ill-conditioned covariance matrices.

1 open issue
What changed in this PR

This pull request updates the Black–Litterman lecture to (1) fix “curve decolletage” plotting cells that break under NumPy 2 / Matplotlib scalar-conversion rules and (2) substantially revise and extend the lecture’s narrative, simulations, figures, exercises, and references to better motivate estimation error, shrinkage, views, and robustness interpretations.

Changes:

  • Fix and refactor the decolletage plotting code (single reusable function, clearer styling/legend) to avoid NumPy 2 failures caused by passing length-1 arrays where scalars are required.
  • Redesign the main simulated market example and expand the lecture with new sections on few-asset views via (P,Q,\Omega), whether shrinkage pays (Monte Carlo certainty-equivalent losses), and robustness/Bayesian interpretations.
  • Refresh appendix/exercises, improve captions/wording/notation consistency, and add new bibliography entries (He–Litterman 1999; Garlappi–Uppal–Wang 2007; DeMiguel–Garlappi–Uppal 2009).

Key review notes to address before approval (from inline comments):

  • Avoid explicit matrix inverses (np.linalg.inv) in multiple places; prefer linear solves for numerical stability (especially with ill-conditioned sample covariance matrices).
  • quad_form currently recomputes an inverse per call; compute quadratic forms via np.linalg.solve and support both scalar points and grid arrays without explicit inversion.
  • Clarify the N_app - 1 off-by-one workaround by slicing the generator output, rather than coupling loop logic to the generator’s internal sizing.
File Summary
lectures/​black_litterman.md Major lecture rewrite (new simulated example; added sections on views, shrinkage payoffs, robustness/Bayesian reading; updated exercises/appendix) and refactored decolletage plotting to work under NumPy 2.
lectures/​_static/​quant-econ.bib Adds BibTeX entries required by the revised lecture’s new citations (He–Litterman 1999; Garlappi–Uppal–Wang 2007; DeMiguel–Garlappi–Uppal 2009).

Review effort: Balanced

Comment thread lectures/black_litterman.md Resolved
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@github-actions
github-actions Bot temporarily deployed to pull request November 4, 2026 22:29 Inactive
@mmcky
mmcky merged commit 6ad797a into main Nov 4, 2026
10 checks passed
@mmcky
mmcky deleted the nov_penn3 branch November 4, 2026 23:38

This branch was previously deployed

1 inactive deployment
pull request — 771d2a08 Deployed Nov 4, 2026 by github-actions[bot]
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.

3 participants