Returns a function that calculates an approximation to the Hessian matrix
of the given function. The vector of start values are used to determine
the number of parameters required by the function, and to scale the
step-size. The generated function accepts a vector of
parameter values and a vector of x data points and returns a matrix,
where each row with p*(p+1)/2 columns, one for each unique entry in
the Hessian evaluated at the corresponding x value.
Examples:
(use '(incanter core optimize datasets charts))
(defn f [theta x]
(+ (nth theta 0)
(div (* x (- (nth theta 1) (nth theta 0)))
(+ (nth theta 2) x))))
(def start [20 200 100])
(def data (to-matrix (get-dataset :thurstone)))
(def x (sel data :cols 1))
(def y (sel data :cols 0))
;; view the data
(view (scatter-plot x y))
(time (def hess (hessian f start)))
(time (doall (hess start x)))
Comments top
No comments for hessian. Log in to add a comment.