All of the previous methods require a root finding function. We're going to implement a secant method for MLE purposes. This method is quite universal in the sense that it doesn't require anything more than a function. Other methods might require existence and analytic form of the first derivative or might put some restrictions on the function class. As most of the root finding methods, the secant method is a recurrent method, that is, the one which should repeat a step until some convergence criteria is met.
This recurrence relation defines the secant method:
As you can see the method requires two initial values and that should ideally lie close to the root. The implementation of this root finding method is pretty straightforward as in Secant.hs
.
Here we define a data structure, Secant
that might be either a converged version (ConvergedSecant
) or an in-progress structure (Secant
). At first, we define two utility methods, isZero
and invDerivative
. The isZero...