Implement manual Cholesky for multivariate normal sampling with speedup - #3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
GaussianGridCache1Dand related functions (prepare_gaussian_grid_cache_1d,fill_q_samples_for_true_index) insrc/npkit/_scan.pyto cache whitened means, Cholesky factors, and efficiently generate whitened scan curves and toy samples for 1D Gaussian models.GaussianLikelihoodto use the cached Cholesky factor for generating samples, ensuring all samples are produced in whitened coordinates. [1] [2]Neyman belt construction and statistical routines:
build_beltandbuild_belts_from_gridinsrc/npkit/neyman.pyto use the new Gaussian grid cache and whitened scan logic, removing redundant code and improving numerical stability. [1] [2]profile_curve_from_likelihoodinsrc/npkit/stats.pyto 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:
invert_beltandprofile_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.