stan-dev / stan-dev/math

boundaries should be exclusive in positive-constrained distributions like lognormal

Open
#1,968 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

Lines 26-27 of stan/math/prim/prob/lognormal_lpdf.hpp are:

  check_not_nan(function, "Random variable", y);
  check_nonnegative(function, "Random variable", y);

They should be replaced with:

  check_positive_finite(function, "Random variable", y);

because 0 is not in the support of a lognormal.

For comparison, the test is implemented properly in gamma_lpdf.hpp.

There may be other

Current Version:

v3.2.0

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 with stan/math/prim/prob/lognormal_lpdf.hpp lines 26-27 and compare the validation used in gamma_lpdf.hpp. Update the lognormal random-variable check so zero is rejected, then review related positive-constrained distributions for the same boundary issue; done when the lognormal support check is exclusive.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.