stan-dev / stan-dev/math

multiply_log(0, 0) has infinite gradient

Open
#2,494 12 comments 0 reactions 0 assignees View on GitHub

@SteveBronder is already working on this.

Since Feb 13, 2025.

  • #3147 by @SteveBronder — open
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

For more details, see https://discourse.mc-stan.org/t/non-linear-modelling-michaelis-menten/22736/8

Example

The gradient for poisson_lpmf(0 | lambda) is infinite at lambda = 0.

Suggested fix

@nhuurre writes on discourse:

We should just special-case a=0.0 like we do with a=1.0

Current Version:

v4.0.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the multiply_log implementation and its existing special case for a=1.0. Check the linked discussion and pull request for the proposed scope, then run the relevant gradient tests. Done means poisson_lpmf(0 | lambda) no longer has an infinite gradient at lambda=0.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.