Product Prior¶
Product of independent marginal distributions with latent space transformations.
Overview¶
Product defines a prior as a product of independent 1D marginals, each with a
bijective map to a chosen latent space. It extends the abstract base class
TransformedPrior, which defines the forward/inverse interface.
Product supports two latent-space modes:
"hypercube": Maps to/from a bounded hypercube (used with Flow)"standard_normal": Maps to/from standard normal space (used with GaussianFullCov)
Supported Distributions¶
| Type | Parameters | Description |
|---|---|---|
uniform |
low, high |
Uniform distribution over [low, high] |
normal |
mean, std |
Gaussian distribution |
cosine |
low, high |
Distribution with pdf ∝ cos(θ) — use for inclination-like angles |
sine |
low, high |
Distribution with pdf ∝ sin(θ) — use for declination-like angles |
uvol |
low, high |
Uniform-in-volume (pdf ∝ r²) — use for a radial coordinate in 3D |
triangular |
a, c, b |
Triangular distribution (min a, mode c, max b) |
lognormal |
mean, std |
Log-normal distribution. Only supported with "standard_normal" mode; raises ValueError with "hypercube" mode |
fixed |
value |
Fixed (non-inferred) parameter — excluded from the latent space |
Fixed Parameters¶
Use the fixed distribution type to hold a parameter constant. Fixed parameters
are excluded from the inferred parameter space but still appear in the full
parameter vector passed to the simulator:
simulator:
_target_: falcon.priors.Product
priors:
- ['normal', 0.0, 1.0] # Inferred
- ['fixed', 3.14] # Held constant
- ['uniform', -1.0, 1.0] # Inferred
Usage¶
from falcon.priors import Product
prior = Product(
priors=[
('normal', 0.0, 1.0),
('uniform', -10.0, 10.0),
]
)
# Sample from prior — output shape is (1000, prior.full_param_dim)
samples = prior.simulate_batch(1000)
# Transform to/from latent space
z = prior.inverse(samples, mode="standard_normal")
x = prior.forward(z, mode="standard_normal")
param_dim vs full_param_dim
prior.param_dim is the number of free (non-fixed) parameters — the
dimension of the latent space seen by estimators. prior.full_param_dim
is the total output dimension including fixed parameters. The simulator
always receives the full vector.
YAML Configuration¶
With Flow estimator¶
simulator:
_target_: falcon.priors.Product
priors:
- ['uniform', -100.0, 100.0]
- ['uniform', -100.0, 100.0]
With GaussianFullCov estimator¶
Class Reference¶
TransformedPrior
¶
Bases: ABC
Base class for priors that support latent space transformations.
Subclasses must implement forward() and inverse() with a mode parameter: - forward(z, mode): latent space -> parameter space - inverse(x, mode): parameter space -> latent space
Modes
- "hypercube": Maps to/from bounded hypercube. Use with Flow estimator.
- "standard_normal": Maps to/from N(0, I). Use with Gaussian estimator.
This base class is used for type checking in estimators like Gaussian that require the transformation interface.
Product
¶
Bases: TransformedPrior
Maps between target distributions and a latent space (hypercube or standard normal).
Supports bi-directional transformation with mode selection at call time
- forward(z, mode): latent space -> target distribution
- inverse(x, mode): target distribution -> latent space
Modes
- "hypercube": Maps to/from hypercube domain (default [-2, 2]). Use with Flow estimator.
- "standard_normal": Maps to/from N(0, I). Use with Gaussian estimator.
Supported distribution types and their required parameters
- "uniform": Linear mapping. Parameters: low, high.
- "cosine": Uses acos transform for pdf ∝ sin(angle). Parameters: low, high.
- "sine": Uses asin transform. Parameters: low, high.
- "uvol": Uniform-in-volume. Parameters: low, high.
- "normal": Normal distribution. Parameters: mean, std.
- "triangular": Triangular distribution. Parameters: a (min), c (mode), b (max).
- "fixed": Fixed value (excluded from latent space). Parameters: value.
Two roles exclude a parameter from the latent space, i.e. from what the estimator infers. They differ in what the simulator receives: - "fixed": pinned to a constant, so it cannot influence the data at all. - marginalize=[i, ...]: keeps its declared distribution and is redrawn from it on every call, so it still varies and still broadens the likelihood -- the estimator learns the posterior marginalized over it. Use for nuisance parameters. Note that forward() cannot recover a marginalized value from the latent vector, so the corresponding column of any generated sample is a prior draw, not a posterior draw; the marginals of the remaining parameters are unaffected.
Example
prior = Product([ ("uniform", -100.0, 100.0), ("fixed", 5.0), # Fixed parameter, not in latent space ("normal", 0.0, 1.0), ("uniform", 0.0, 1.0), # Nuisance, marginalized over ], marginalize=[3])
Latent space has dim=2 (only free params)¶
Output space has dim=4 (includes fixed and marginalized params)¶
For Gaussian estimator (standard normal latent space)¶
z = prior.inverse(theta, mode="standard_normal") # theta: (..., 4) -> z: (..., 2) theta = prior.forward(z, mode="standard_normal") # z: (..., 2) -> theta: (..., 4)
For Flow estimator (hypercube latent space)¶
u = prior.inverse(theta, mode="hypercube") theta = prior.forward(u, mode="hypercube")
Initialize Product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
priors
|
List of tuples (dist_type, param1, param2, ...). |
[]
|
|
hypercube_range
|
Range for hypercube mode (default: [-2, 2]). |
[-2, 2]
|
|
marginalize
|
Optional list of parameter indices to marginalize over. A marginalized param keeps its declared distribution and is sampled normally into the full/simulator vector (so it still affects the data), but is excluded from the latent/inference space -- the estimator learns the posterior marginalized over it. Like "fixed" in that it is absent from the latent space, but drawn from its own prior (a fresh random draw in forward()) rather than held at a constant value. Composes with everything downstream because the latent space is simply smaller. |
None
|
Source code in src/falcon/priors/product.py
forward
¶
Map from latent space to target distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
Tensor of shape (..., param_dim) in latent space (free params only). |
required | |
mode
|
"hypercube" or "standard_normal". |
'hypercube'
|
Returns:
| Type | Description |
|---|---|
|
Tensor of shape (..., full_param_dim) in target distribution space. |
Source code in src/falcon/priors/product.py
inverse
¶
Map from target distribution to latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor of shape (..., full_param_dim) in target distribution space. |
required | |
mode
|
"hypercube" or "standard_normal". |
'hypercube'
|
Returns:
| Type | Description |
|---|---|
|
Tensor of shape (..., param_dim) in latent space (free params only). |
Source code in src/falcon/priors/product.py
simulate_batch
¶
Generate samples from the target distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
Number of samples. |
required |
Returns:
| Type | Description |
|---|---|
|
numpy array of shape (batch_size, full_param_dim) in target distribution space. |