stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
756 stars 188 forks source link

Add score() function #461

Open syclik opened 8 years ago

syclik commented 8 years ago

Summary:

This is from @bgoodri on stan-dev/stan#605.

Add a score() function to the language. It would require nested autodiff.

Description:

Add the score function.

See: https://en.wikipedia.org/wiki/Score_(statistics)

Additional Information:

I'm not sure exactly how this would work. @bgoodri, might need some help.

Current Version:

v2.13.0

bgoodri commented 8 years ago

A score() function would be good --- to calculate the derivative of the log-likelihood, usually on a per observation basis --- but it would also be good to have a gradient() function to calculate the derivative of an expression to feed into the log-likelihood. But I'm not sure how high a priority this would be relative to other things because in 2.13.0 you can get to the gradient(), jacobian(), etc. functions in Stan Math by writing your own C++.

bob-carpenter commented 8 years ago

You have to be careful to use nested autodiff properly. The gradient() function is set up to do that, but you have to work in a purely nested fashion as we do in the Jacobian calcs for the ODE solver.

bob-carpenter commented 7 years ago

Also, I don't know how we could return the value of the derivative of the log density until it's been completely defined. Then we can't use it for anything in the density, or the density will change. Where do you need this function and for what?

jvaara commented 7 years ago

I have been waiting for this function request and hoping to get to use it for Design of Experiment via Information matrix.

bob-carpenter commented 7 years ago

We don't even have a technical spec for how this could work, so it's not going to be done soon unless someone figures out how to do it.

On Jan 27, 2017, at 8:14 AM, jvaara notifications@github.com wrote:

I have been watching this function request and hoping to use it for Design of Experiment via Information matrix.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.