Quantitative thermodynamical, dynamical and magnetic properties of the solar and stellar plasmas are obtained by interpreting their emergent non-polarized and polarized spectrum. This inference requires the selection of a set of spectral lines particularly sensitive to the physical conditions in the plasma and a suitable parametric model of the solar/stellar atmosphere. Nonlinear inversion codes are then used to fit the model to the observations. However, the presence of systematic effects like nearby or blended spectral lines, telluric absorption or incorrect correction of the continuum, among others, can strongly affect the results. We present an extension to current inversion codes that can deal with these effects in a transparent way. The resulting algorithm is very simple and can be applied to any existing inversion code with the addition of a few lines of code as an extra step in each iteration.
[abridged] Inversion techniques are the most powerful methods to obtain information about the thermodynamical and magnetic properties of solar and stellar atmospheres. In the last years, we have witnessed the development of highly sophisticated inversion codes that are now widely applied to spectro-polarimetric observations. The majority of these inversion codes are based on the optimization of a complicated non-linear merit function. However, no reliable and statistically well-defined confidence intervals can be obtained for the parameters inferred from the