Loss Functions¶
Loss functions control how residuals between data and model are computed during
fitting. Pass a loss function as the loss argument to any model's fit()
method.
chi2_loss¶
danish.loss.chi2_loss
module-attribute
¶
Standard chi residual, equivalent to systematic_loss(0).
Assumes Gaussian read noise plus Poisson shot noise:
(data - model) / sqrt(var + model). This is the default loss function.
systematic_loss¶
danish.loss.systematic_loss ¶
Return a loss function that adds a fractional systematic noise floor.
The effective variance is var + model + (alpha * model)**2, where
alpha is the fractional systematic uncertainty (e.g. 0.02 = 2%).
This caps the effective SNR per pixel, preventing unmodeled correlated
residuals (e.g. from atmospheric fluctuations or mirror figure errors)
from dominating the fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Fractional systematic uncertainty. Typical values are 0.01–0.05. |
required |
Returns:
| Type | Description |
|---|---|
callable
|
Loss function with signature |