ifw-odp
2.0.0-alpha
|
#include "clipm_priv_optimize.h"
#include "clipm_math.h"
#include "clipm_compatibility_replacements.h"
#include "clipm_priv_error.h"
#include "clipm_priv_matrix.h"
#include "clipm_priv_vector.h"
Functions | |
cpl_error_code | clipm_priv_optimize_gaussian (const cpl_vector *xvalues, const cpl_vector *xsigmas, const cpl_vector *yvalues, const cpl_vector *ysigmas, cpl_fit_mode fit_opts, int max_iterations, double *x0, double *x0_uncertainty, double *sigma, double *sigma_uncertainty, double *fwhm, double *fwhm_uncertainty, double *area, double *offset, double *mse, double *red_chisq, cpl_matrix **covariance, cpl_size *lower_ndx, cpl_size *upper_ndx) |
Apply a Gaussian fitting until it is successful. More... | |
cpl_error_code | clipm_priv_optimize_downhill_simplex (cpl_vector *fit_params, const cpl_vector *start_delta, const cpl_vector *precision,(cpl_vector *params, void *other), void *other_func_par, int max_iterations, double *optimum, int *done_iterations) |
Optimize a set of parameters using the Downhill Simplex method by Nelder and Mead (also known as the "Amoeba" method). More... | |
cpl_error_code clipm_priv_optimize_downhill_simplex | ( | cpl_vector * | fit_params, |
const cpl_vector * | start_delta, | ||
const cpl_vector * | precision, | ||
(cpl_vector *params,void *other) | , | ||
void * | other_func_par, | ||
int | max_iterations, | ||
double * | optimum, | ||
int * | done_iterations | ||
) |
Optimize a set of parameters using the Downhill Simplex method by Nelder and Mead (also known as the "Amoeba" method).
fit_params | Vector containing the parameters to be optimized, which must be set to an initial guess, and will contain the result at the end |
start_delta | Vector containing a set of parameter step sizes for the start of the optimization |
precision | Optional vector containing respective precision limits (> 0) which must be met for convergence, can be NULL |
evalfunc | Pointer to function which evaluates the parameters and returns a value which must be minimal in the optimum (for example an error value, or the inverse or negative of a matching), taking as first argument the parameter vector, and as second argument an arbitrary pointer (to provide any other data) |
other_func_par | Arbitrary pointer used as the input for the second argument of evalfunc, for example a pointer to a dataset or a reference to a struct of pointers and further parameters |
max_iterations | The maximum number of iterations |
optimum | Optional output return value of evalfunc with optimized parameters, can be NULL |
done_iterations | Optional output of number of performed iterations, can be NULL |
Limitations:
cpl_error_code clipm_priv_optimize_gaussian | ( | const cpl_vector * | xvalues, |
const cpl_vector * | xsigmas, | ||
const cpl_vector * | yvalues, | ||
const cpl_vector * | ysigmas, | ||
cpl_fit_mode | fit_opts, | ||
int | max_iterations, | ||
double * | x0, | ||
double * | x0_uncertainty, | ||
double * | sigma, | ||
double * | sigma_uncertainty, | ||
double * | fwhm, | ||
double * | fwhm_uncertainty, | ||
double * | area, | ||
double * | offset, | ||
double * | mse, | ||
double * | red_chisq, | ||
cpl_matrix ** | covariance, | ||
cpl_size * | lower_ndx, | ||
cpl_size * | upper_ndx | ||
) |
Apply a Gaussian fitting until it is successful.
xvalues | Positions to fit |
xsigmas | Uncertainties of positions to fit (NOT supported) |
yvalues | Values to fit |
ysigmas | Uncertainties of values to fit |
fit_opts | Fitting options: bitwise combination of CPL_FIT_CENTROID, CPL_FIT_STDEV, CPL_FIT_AREA, CPL_FIT_OFFSET or CPL_FIT_ALL (for all above) |
max_iterations | Maximum number of iterations |
x0 | (output) Center of best fit gaussian. If CPL_FIT_CENTROID is not set, this is also an input parameter. |
x0_uncertainty | (output) Optional uncertainty of x0. |
sigma | (output) Width of best fit gaussian. A positive number on success. If CPL_FIT_STDEV is not set, this is also an input parameter. |
sigma_uncertainty | (output) Optional uncertainty of sigma. |
fwhm | (output) FWHM of best fit gaussian. A positive number on success. |
fwhm_uncertainty | (output) Optional uncertainty of fwhm. |
area | (output) Area of gaussian. A positive number on success. If CPL_FIT_AREA is not set, this is also an input parameter. |
offset | (output) Fitted background level. If CPL_FIT_OFFSET is not set, this is also an input parameter. |
mse | (output) If non-NULL, the mean squared error of the best fit is returned. |
red_chisq | (output) If non-NULL, the reduced chi square of the best fit is returned. This requires the ysigmas to be specified. |
covariance | (output) If non-NULL, the formal covariance matrix of the best fit is returned. This requires ysigmas to be specified. The order of fit parameters in the covariance matrix is defined as (x0, sigma, area, offset), for example the (3,3) element of the matrix (counting from zero) is the variance of the fitted offset. The matrix must be deallocated by calling cpl_matrix_delete() . On error, NULL is returned. |
lower_ndx | Output lower index of iteration window, can be NULL |
upper_ndx | Output upper index of iteration window, can be NULL |