--- myst: substitutions: include: python: "`numpy array`" cpp: "`vector`" --- (calibration_classes_functions_observations_calibration_classes_estimate_residuals)= # Estimate custom residuals Once the estimate has been performed, both *a priori* and *a posteriori* residuals can be computed. Since *a priori* and *a posteriori* estimates depend on the chosen algorithm, their formulas are not detailed here. It is also possible to re-evaluate residuals for any custom set of parameter values provided by the user. This can be done through ````{only} cpp ```cpp void estimateCustomResiduals(string resName, int theta_nb, double *theta_val); ``` ```` ````{only} py ```python estimateCustomResiduals(resName, theta_nb, theta_val) ``` ```` It takes three arguments, which are: 1. **resName**: a tag identifying the stored set of residuals; 2. **theta_nb**: the number of parameter values in the array (must match `_nPar`); 3. **theta_val**: an array containing the parameter values. For convenience, this method can be called with a {{include[language]}}, as shown below ````{only} cpp ```cpp vector mypar = {0., 2., 3.}; mycal->estimateCustomResiduals("set1", mypar.size(), &mypar[0]); ``` ```` ````{only} py ```python import numpy as np mypar = np.array([0., 2., 3.]) mycal.estimateCustomResiduals("set1", len(mpar), mypar) ``` ```` This feature allows re-estimating the residuals based on the available sample after the *a posteriori* distributions have been calibrated. A common use case is Markov chain Monte Carlo methods, where it may be necessary to discard the burn-in phase before evaluating residuals. Once created, the custom set can be used in the `drawResiduals` function, as discussed in [](#calibration_classes_functions_observations_calibration_classes_draw_residuals).