mescla.mixing.lsq.solve_ratios

mescla.mixing.lsq.solve_ratios(F, y, weights=None, non_negative=True, censored=None)[source]

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

Parameters:
  • F (ndarray, shape (ns, ne)) – End-member concentrations, species down the rows.

  • y (ndarray, shape (ns,)) – The mixed sample. nan marks a species that was not analysed in this sample; it is simply left out of this sample’s fit.

  • weights (ndarray, shape (ns,), optional) – 1 / sigma**2 per species. Uniform when omitted.

  • non_negative (bool, default True) – Apply the active-set non-negativity step. Setting this to False is diagnostically useful: a strongly negative unconstrained ratio says the sample lies outside the mixing hull, which clipping would hide.

  • censored (ndarray of bool, shape (ns,), optional) – True where y holds a detection limit rather than a measurement. A non-detect says the true value lies in [0, limit], so it constrains the fit only from above: it is ignored while the model predicts a concentration below the limit, and enters as a measurement at the limit when the model predicts more. Solved by an outer active set.

Returns:

  • ratios (ndarray, shape (ne,))

  • active (ndarray of bool, shape (ne,)) – Which end-members were forced to zero.

Return type:

tuple[ndarray, ndarray]