mescla.mixing.ml¶
MIX: maximum-likelihood mixing ratios with uncertain end-members.
After Carrera, J., Vazquez-Sune, E., Castillo, O. and Sanchez-Vila, X. (2004), A methodology to compute mixing ratios with uncertain end-members, Water Resources Research 40, W12101.
The idea¶
Conventional mixing calculations assume the end-members are known exactly. They almost never are: their uncertainty comes from spatial and temporal variability and from conceptual error, not from the laboratory. Mixed samples, by contrast, carry mostly analytical error, which is small.
So the mixtures contain information about the end-members. MIX exploits that by estimating mixing ratios and end-member compositions jointly, maximising
subject to the mixing equations, sum_e lambda_pe = 1 and lambda_pe >= 0.
Here z_s stacks every analysis of species s – end-members first, then
samples – and A_s is its covariance.
The consequence is the one that matters in practice: because all samples are used together, the estimate improves as samples accumulate. Least squares, which treats each sample independently, does not improve at all.
Implementation note¶
The paper eliminates the concentrations analytically (its equation 20) and solves the remaining nonlinear system for the ratios by Newton-Raphson with an active set. This module instead carries the end-member concentrations as explicit unknowns and alternates two closed-form steps – block coordinate descent on the same likelihood:
Ratios fixed -> update the concentrations. One weighted linear least-squares solve of size
ne x neper species.Concentrations fixed -> update the ratios. One constrained least-squares solve per sample (
mescla.mixing.lsq.solve_ratios()), which handles the simplex constraints exactly.
Each step decreases the objective, so convergence to a local optimum is monotone and
needs no line search. profile_objective() reproduces the paper’s eliminated
objective (equation 21) and is used in the test suite to confirm the two formulations
agree.
The restriction is that errors are taken to be independent across both species and
samples (diagonal A_s). The paper permits correlation across samples within one
species, which would let it filter a systematic handling error affecting a single
species; that generalisation is not implemented here.
Functions
Carrera et al. (2004) equation 28: how much estimation improved the end-members. |
|
Estimate mixing ratios and end-member concentrations jointly (MIX). |
|
The paper's eliminated objective (equation 21), for cross-checking. |
Classes