On Thu, Aug 06, 2009 at 03:37:25AM -0700, roessli bertrand wrote: > Hello, > > Just have a comment which is also a question concerning dfdp.m > > The help states > "dp= fractional increment of p for numerical derivatives" > which is fine, but the problem comes that usually nobody knows > which step to use to calculate the derivatives. > > Would it no be better to choose the step in a similar way than it is done > in __bgsmin.cc?: > > SQRT_EPS = sqrt(DBL_EPSILON); > diff = exp(log(DBL_EPSILON)/3.0); > // get 1st derivative by central difference > for (j=0; j<k; j++) { > p = parameter(j); > // determine delta for finite differencing > test = (fabs(p) + SQRT_EPS) * SQRT_EPS > diff; > if (test) delta = (fabs(p) + SQRT_EPS) * SQRT_EPS; > else delta = diff; > // right side > parameter(j) = p + delta; > success = __bfgsmin_obj(obj_right, f, f_args, parameter, > minarg); > if (!success) error("__numgradient: objective function > failed, can't compute numeric gradient"); > // left size > parameter(j) = p - delta; > success = __bfgsmin_obj(obj_left, f, f_args, parameter, > minarg); > if (!success) error("__numgradient: objective function > failed, can't compute numeric gradient"); parameter(j) = p; > // restore original parameter for next round > g(j) = (obj_right - obj_left) / (2.0*delta); > }
dfdp.m is meant to be called by leasqr.m, which chooses a default of .001 for dp. This may not be optimal in some cases, but why do you think the result of the code above is better? Olaf ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Octave-dev mailing list Octave-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/octave-dev