The error model
The error model describes the aleatoric noise on your measured concentrations. You set it once on the configuration, and Catalax samples it during inference as thesigma_y parameter.
yerrs. This matches the behaviour of earlier versions, so existing scripts keep working unchanged.
Available noise models
All error models live undercmc.error and describe the noise standard deviation in concentration space.
- Default scale:
scale,median, andratedefault tomean(yerrs), so in the common case you only set the spread. - Per species by default: each observable state gets its own noise level. Pass
shared=Trueto tie them all to a single scalar. - Direct values: the sampled
sigma_yis the actual noise standard deviation. You read it straight fromresults.get_samples()["sigma_y"]with no back transform.
Concentration space and the surrogate pushforward
You always describe the noise in concentration space, because that is where you have a feel for measurement error. Catalax handles the rest.- In an integrated fit, the concentration noise is the likelihood scale directly.
- In a surrogate rate-matching fit, the likelihood compares rates, not concentrations. Catalax pushes your concentration noise forward into rate space through the surrogate Jacobian. This forward map is well behaved and needs no inverse. The result is that
sigma_ystays a concentration-space quantity you can interpret and reuse for predictions.
error_model object works in both modes.
Choosing a noise model
The main choice is between the half-normal default and a log-normal. A half-normal places its highest density at zero. When a species is fit very well, its noise level wants to be small, and the half-normal lets it slide all the way to the zero boundary. A scale parameter pinned at zero creates a funnel geometry that the sampler cannot navigate, which shows up as divergences. A log-normal has zero density at zero and is sampled in log space, which has no boundary. A weakly constrained noise level settles at the prior median instead of collapsing. This keeps per-species noise while removing the funnel.- Set
mediannear the typical noise across your species rather than the largest one. - Use a wider
sigmain log space so a single prior covers small and large noise levels at the same time. A value around1.5spans roughly two orders of magnitude.
cmc.error.HalfNormal(shared=True) gives a single scalar noise level, which is far less prone to collapse than a per-species half-normal.
Diagnosing divergences
Divergences mark places where the sampler could not follow the posterior geometry. Catalax records them on every run and exposes three views on the result.diverging_samples frame has one row per diverging draw, with a chain and draw index and a column for every parameter. Vector parameters such as a per-species sigma_y expand to sigma_y[0], sigma_y[1], and so on. This tells you where in parameter space the divergences happen.
Reducing divergences
Work through these in order.-
Match the noise model to the data. If the diverging samples cluster at small
sigma_y, switch that fit tocmc.error.LogNormaland set a sensible median. -
Raise the target acceptance probability. A higher value forces smaller steps, which helps the sampler follow curved correlation ridges between kinetic parameters.
-
Use log-scale priors for parameters that span orders of magnitude. A
cmc.priors.LogUniformprior gives a scale-free prior over a positive range. When you switch a parameter fromUniformtoLogUniform, raise its lower bound to a physically plausible floor, because the log-uniform prior places equal weight on each decade and a very small lower bound concentrates prior mass at implausibly small values.

