Broken-alpha: Genpdf snvar conditioning#1639
Open
trivialTZ wants to merge 5 commits intoRickKessler:masterfrom
Open
Broken-alpha: Genpdf snvar conditioning#1639trivialTZ wants to merge 5 commits intoRickKessler:masterfrom
trivialTZ wants to merge 5 commits intoRickKessler:masterfrom
Conversation
Extends GENPDF map conditioning so that extra dimensions can reference SN-generated variables (SALT2x1, SALT2c, RV, AV) in addition to HOSTLIB columns. This enables simulation of x1-dependent alpha distributions (broken-alpha) via GENPDF maps. Changes: - Add PTRVAL_SNVAR and USE_HOSTLIB fields to GENPDF struct - Fall back to checkSNvar_HOSTLIB_WGTMAP() when HOSTLIB lookup fails - Raise MXROW_GENPDF from 15000 to 50000 for dense conditioning maps - Update funVal_genPDF and getRan_genPDF to read from SNVAR pointers Motivated by Ginolin et al. 2025 (ZTF DR2) broken-alpha finding.
char string[40] overflows when MAPSIZE >= ~1000 because the formatted string "allocate %.2f MB for %d bins and NFUN=%d" can reach 49 bytes. Widen to 100. This caused a __chk_fail_overflow crash (SIGTRAP) when loading dense GENPDF maps with >10k rows. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pdf-snvar-conditioning # Conflicts: # src/sntools_genPDF.c
…npdf-snvar-conditioning
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.
Extends GENPDF map conditioning so that extra dimensions can reference SN-generated variables (SALT2x1, SALT2c, RV, AV) in addition to HOSTLIB columns. This enables simulation of x1-dependent alpha distributions (broken-alpha) via GENPDF maps.
Changes:
Build to achieve functionality for simulation similar to Ginolin et al. 2025 (ZTF DR2) broken-alpha finding.
Code changes
1. New struct fields (
sntools_genPDF.h)Each conditioning dimension of a GENPDF map now tracks which source to read from at runtime and, for SNVARs, stores a direct pointer to the simulator's internal value.
Also raised
MXROW_GENPDFfrom 15000 to 50000 to support dense 2D maps (e.g., a fine alpha-vs-x1 grid can easily require 10k+ rows).2. Safe initialization (two sites)
Both
init_genPDF()(file-based maps) andinit_genPDF_from_GenGauss()(Gaussian maps) now initialize the new fields:Defaults ensure backward compatibility: existing maps that only use HOSTLIB variables are unaffected.
3. Variable resolution with SNVAR fallback (
init_genPDF)The init-time loop that validates conditioning variables is changed from a single HOSTLIB-or-crash lookup to a three-step fallback:
Before:
After:
Step 2 reuses the existing upstream function
checkSNvar_HOSTLIB_WGTMAP()(insntools_host.c) which maps variable names to live pointers:"SALT2x1"/"x1"→GENLC.ptr_SHAPEPAR"SALT2c"/"c"→&GENLC.SALT2c"AV"→&GENLC.AV"RV"→&GENLC.RV4. Runtime value retrieval (three sites)
Three functions that read conditioning values during simulation are updated with the same if/else pattern:
funVal_genPDF()— evaluates P(x | conditions)getRan_genPDF()— accept/reject random draw, sets up conditioning valuesgetRan_genPDF()— prints conditioning values when LDMP is onBefore (all three):
After (all three):
Usage: simulating broken-alpha
Step 1: Write a GENPDF map file
The map defines
P(SALT2ALPHA | SALT2x1). The first column is the generated parameter, middle columns are conditioning variables, and the last column is probability.Minimal example (
genpdf_alpha_vs_x1.DAT):This encodes: at low x1 (x1=-3), alpha around 0.11 is strongly preferred; at high x1 (x1=+3), alpha~0.19 is preferred (broken-alpha population)
For precision studies (e.g., hard break at a specific x1), use a dense grid. Example with Ginolin+2024 truth values (alpha_low=0.280, alpha_high=0.088, break at x1=-0.49):
Dense maps require
MXROW_GENPDF >= 50000(included in this PR).Step 2: Reference the map in
snlc_siminputImportant: The x1 distribution (
GENPEAK/GENSIGMA/GENRANGE_SALT2x1) must be defined so that x1 is generated first; the GENPDF map then draws alpha conditioned on the already-generated x1 value.Step 3: Verify in the log
On successful init,
snlc_simprints:Pippin YAML example