- astropy.modeling.statistic.leastsquare(measured_vals, updated_model, weights, *x)¶
Least square statistic, with optional weights, in N-dimensions.
Measured data values. Will be cast to array whose shape must match the array-cast of the evaluated model.
Model with parameters set by the current iteration of the optimizer. when evaluated on “x”, must return array of shape “measured_vals”
Array of weights to apply to each residual.
Independent variables on which to evaluate the model.
The sum of least squares.
modelinghave broadcasting rules that try to match inputs with outputs with Model shapes. Numpy arrays have flexible broadcasting rules, so mismatched shapes can often be made compatible. To ensure data matches the model we must perform shape comparison and leverage the Numpy arithmetic functions. This can obfuscate arithmetic computation overrides, like with Quantities. Implement a custom statistic for more direct control.