mescla.mixing.lsq

Constrained least squares for mixing ratios with known end-members.

Implements Carrera et al. (2004) equation 9: maximise the Gaussian likelihood of one sample subject to the ratios summing to one, which gives a small linearly constrained least-squares system.

Two structural facts make this cheap and robust:

  • When every sample shares the same species and covariance, the KKT coefficient matrix is identical for all samples, so it is factorised once.

  • Because the weight matrix is positive definite the objective is convex and the sum-to-one constraint makes lambda <= 1 automatic, so the feasible region is the simplex and any KKT point is the global optimum. Non-negativity is imposed by a primal active set over the faces of that simplex – one that releases constraints as well as adding them, which is what makes the KKT point reachable. See _solve_active_set().

Functions

mixing_ratios

Mixing ratios for every sample, by weighted constrained least squares.

solve_ratios

Mixing ratios for a single sample (the low-level kernel).