Skip to content

Hessian (d2logp) has the wrong sign #6310

@cscheffler

Description

@cscheffler

In PyMC, the Hessian of the a model is defined as $-\nabla\nabla\log f$ and not $\nabla\nabla\log f$ which is the generally accepted mathematical definition, as the collection of second-order derivatives.

I accept that there is probably a good reason for computing the negative Hessian rather than the Hessian but, for clarity when reading the code and documentation, could these functions be renamed to indicate that this is the negative Hessian?

Context: For pedagogical/demonstration purposes, I am implementing the Laplace approximation using the logp, dlogp, and d2logp functions and the sign error in d2logp took me a long time to figure out, eventually by looking through the code and finding the definition of aesaraf.hessian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions