Multivariable covariant parameter space priors#135
Multivariable covariant parameter space priors#135kayhangultekin wants to merge 6 commits intodevfrom
Conversation
…ses _Param_Space and _Param_Dist so that they can tell if they are using a multi-parameter distribution or if they are using a legacy-style parameter distribution. I created a single new multiparameter distribution, a multivariable Gaussian PD_MVNormal. You give it the means and a covariance matrix, and when doing Latin Hypercube Sampling, it will sample appropriately. I added a new test _Param_Space sublcass PS_Test_Astro_Strong_Covariant_MMBulge. I modified librarian.ipynb to showcase the new parameter space and the joint distribution.
double Schechter function parameters based on Leja+2020. Added a notebook to generate synthetic data with the covariances estimated from the corner plot in the paper. Also added a function to repair the covariance matrix if it's not positive definite. This is a work in progress and will need to be updated with actual covariances from the paper or samples.
…t I will remove before committing upstream.
- Removed several test scripts from git index and moved into a new root 'scratch/' directory. - Ignored 'scratch/' in .gitignore. - Renamed 'new-covariant_double-schecter.ipynb' to 'covariant_double-schecter.ipynb' and tracked the latter.
|
Totally forgot to say that this addresses issue #132 |
|
The additions seem to functioning properly except for two minor compatibility issues that cause some unit tests to fail. The test The Finally, the backslashes on lines 552, 553, 566, and 574 of |
|
@CayenneMatt Good notes. I will update the tests so that they properly check to see if the distribution is multidimensional and check for the appropriate number of parameters. I'll also deal with the backslashes properly. |
Pull Request: Multivariate Priors & Covariant GSMF Implementation
Description
Note the code in this PR and the text here were created with the assistance of AI: Gemini 3 Flash and Gemini 3.1 Pro (Low)
This PR introduces support for multivariate normal prior distributions and implements the Covariant Galaxy Stellar Mass Function (GSMF) using data from Leja+2020.
The core of this update involves extending our parameter space sampling logic to seamlessly handle a mix of univariate and multivariate distributions without breaking the underlying Latin Hypercube continuous sampling.
Todos
Notable points that this PR has either accomplished or will accomplish.
Status
covariant-double-schechter.ipynbnotebook.Key Features & New Classes
PD_MVNormal(New Class): Added tolib_tools.py. This class implements a multivariate normal/Gaussian parameter distribution. It takes a list of parameter names, a means vector, and a covariance matrix. It automatically checks for positive definiteness using Cholesky decomposition to map uniform samples to the multivariate normal space.GSMF_COV_NAMES,GSMF_COV_MEANS, andGSMF_COV_MATRIXtoparam_spaces.py. (The values inGSMF_COV_MATRIXare based on approximations to Leja+2020 data. These need to be updated with the real data when they become available!! This can be done with thecovariant-double-schechter.ipynbnotebook.)PS_Astro_Strong_Covariant_GSMF&PS_Astro_Strong_Covariant_All: New parameter spaces that utilize thePD_MVNormalclass to sample the GSMF parameters covariantly.PS_Test_Astro_Strong_Covariant_MMBulge: A new test parameter space demonstrating how to couple specific parameters (likemmb_mamp_log10andmmb_plaw) using a covariance matrix while keeping others (likemmb_scatter_dex) independent.Architectural Changes & Helper Functions
_transform_samples): Completely rewrote the sample transformation logic in the_Param_Spacebase class. Previously, it assumed a 1:1 mapping between uniform samples and parameter distributions. It now dynamically tracks and slices the correct number of input dimensions required by each_Param_Distobject (whether 1D or ND).extremaproperty) to correctly handle 2D stacking of boundaries for multivariate distributions.repair_covariance(m): Added a new helper function toholodeck/utils.py. This function finds the nearest positive semi-definite matrix by applying eigenvalue decomposition and clipping negative eigenvalues. This is critical for preventing Cholesky decomposition failures when dealing with manually estimated (or slightly numerically unstable) covariance matrices.Testing & Notebooks
covariant-double-schechter.ipynb): Added a dedicated notebook innotebooks/devs/sams/to demonstrate the synthetic dataset generation from the multivariate normal distribution and test the covariance repairing logic.double-schechter.ipynb,librarian.ipynb, andsemi-analytic-models.ipynbto ensure compatibility with the updated parameter space logic.scratch/directory to.gitignoreto keep temporary testing/development scripts untracked.