next up previous
Next: Guess Function (optional) Up: Adding Models Previous: Model Evaluation Function

Derivative Functions

For each parameter, the partial derivate with respect to that parameter must be defined. Since very often the partial derivative also includes the original function itself, the model evaluation is supplied to avoid wasteful calculations. For example, the partial derivative of the Gaussian model with respect to the norm parameter is simply the Gaussian function divided by the norm, and accordingly the derivative function is just:
    def PDeriv3(self, x, y, eval):
        # PD w.r.t. norm
        norm = self.params[2].value
        return(eval/norm)
which is far more efficient than calculating the sines, cosines, and exponentials, etc. if this function where evaluated ``from scratch'' as in the Eval function.



Andrew Ptak 2001-10-11