Changeset 2197 for trunk/psLib/src/math/psMinimize.h
- Timestamp:
- Oct 26, 2004, 11:25:59 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMinimize.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMinimize.h
r1992 r2197 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 29$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-10- 06 23:38:49$10 * @version $Revision: 1.30 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-10-26 21:24:43 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 84 84 85 85 86 /* 87 Bug 203: 88 89 typedef float (*psMinimizeLMChi2Func)(psVector *deriv, const psVector *params, 90 const psVector *x); 91 92 This function takes the current guess for the parameters for which we are 93 trying to get the best values (params), and a single vector (x) of 94 conditions from the array of x values fed into the minimiser. 95 96 bool psMinimizeLMChi2(psMinimization *min, 97 psImage *covar, 98 psVector *params, 99 const psVector *paramMask, 100 const psArray *x, 101 const psVector *y, 102 const psVector *yErr, 103 psMinimizeLMChi2Func func); 104 105 This takes the minimization specs (min), returns the covariance matrix 106 (covar), takes the best guess of initial parameters (params), the parameter 107 mask (paramMask), and takes multiple vectors of conditions in an array (x), 108 the corresponding measured values (y) and errors (yErr) and the function to 109 fit (func). 110 111 For example, for GRB afterglows, I have flux as a function of time and 112 frequency. So I stuff into the "psArray *x" all my time and frequency values 113 (so a whole heap of vectors of size 2), I have the measured values in "y" and 114 errors in "yErr". Then each of the time-frequency pairs are passed to my model 115 function with the current parameters, and the model function returns the flux 116 for that time-frequency pair, and the derivative with respect to each of the 117 parameters. 118 119 This seems reasonable. The only thing we could change would be to have the 120 function be defined: 121 122 typedef psVector* (*psMinimizeLMChi2Func)(psImage *deriv, 123 const psVector *params, 124 const psArray *x); 125 126 So it would return the model value for each of the measurements at once, and 127 return for each the derivatives (so that it returns a matrix). 128 129 What do you think? 130 131 132 133 I'm not sure I understand how LM chi-squared minimization will work with the 134 following function that you define: 135 136 typedef psVector* (*psMinimizeLMChi2Func)(psImage *deriv, 137 const psVector *params, 138 const psArray *x); 139 140 The chi-squared minimization algorithm, as defined in NR, requires that 141 function to be minimized be evaluated at each data point, and that all 142 derivatives, with respect to each parameter, be calculated at each data 143 point. In the above, can I assume that 144 145 x is an array of psVectors, with each vector corresponding to a single 146 data point. 147 148 The returned value has the same length as x. It contains the value of 149 the function at each data point in x. 150 151 deriv: an n-by-p matrix where "n" is the number of data points, and "p" 152 is the number of parameters. The [i][j] element of this matrix 153 holds the derivative of the function at the i-th data point with 154 respect to the j-th parameter. 155 156 157 158 */ 159 160 86 161 // XXX: What if any of these arguments are NULL? 162 163 87 164 typedef 88 165 float (*psMinimizeLMChi2Func)(psVector *deriv, … … 98 175 psMinimizeLMChi2Func func); 99 176 177 178 typedef 179 psVector* (*psMyMinimizeLMChi2Func)(psImage *deriv, 180 const psVector *params, 181 const psArray *x); 182 183 bool psMyMinimizeLMChi2(psMinimization *min, 184 psImage *covar, 185 psVector *params, 186 const psVector *paramMask, 187 const psArray *x, 188 const psVector *y, 189 const psVector *yErr, 190 psMyMinimizeLMChi2Func func); 191 100 192 typedef 101 193 float (*psMinimizePowellFunc)(const psVector *params,
Note:
See TracChangeset
for help on using the changeset viewer.
