Skip to content

Implement manual Cholesky for multivariate normal sampling with speedup - #3

Merged
JaLuka98 merged 2 commits into
mainfrom
speedups-GaussianModel-Whitening
Jun 18, 2026
Merged

Implement manual Cholesky for multivariate normal sampling with speedup#3
JaLuka98 merged 2 commits into
mainfrom
speedups-GaussianModel-Whitening

Conversation

@JaLuka98

Copy link
Copy Markdown
Owner

This pull request refactors and optimizes the Neyman belt construction and related statistical routines for Gaussian models. The main changes introduce a new 1D Gaussian grid cache abstraction that centralizes and streamlines the generation and evaluation of whitened scan curves, improving both performance and code clarity. The simulation and profile curve logic are updated to use this cache, and sampling is now performed in whitened coordinates for better numerical stability.

Gaussian scan and simulation improvements:

  • Added GaussianGridCache1D and related functions (prepare_gaussian_grid_cache_1d, fill_q_samples_for_true_index) in src/npkit/_scan.py to cache whitened means, Cholesky factors, and efficiently generate whitened scan curves and toy samples for 1D Gaussian models.
  • Updated the simulation method in GaussianLikelihood to use the cached Cholesky factor for generating samples, ensuring all samples are produced in whitened coordinates. [1] [2]

Neyman belt construction and statistical routines:

  • Refactored build_belt and build_belts_from_grid in src/npkit/neyman.py to use the new Gaussian grid cache and whitened scan logic, removing redundant code and improving numerical stability. [1] [2]
  • Updated profile_curve_from_likelihood in src/npkit/stats.py to use the Gaussian grid cache for evaluating the profile likelihood curve, and to compute the minimum NLL correctly in whitened coordinates.

Additional integration and API improvements:

  • Added imports and minor refactoring to integrate the new scan cache throughout the codebase, including in invert_belt and profile_curve_from_grid. [1] [2] [3]

These changes collectively improve the efficiency, maintainability, and numerical robustness of Neyman belt construction and statistical inference for Gaussian models.

@JaLuka98 JaLuka98 self-assigned this Jun 18, 2026
@JaLuka98
JaLuka98 merged commit 08ca165 into main Jun 18, 2026
0 of 2 checks passed
@JaLuka98
JaLuka98 deleted the speedups-GaussianModel-Whitening branch June 18, 2026 11:59
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.

1 participant