stan-dev / stan-dev/math

lccdf of beta overflows at reasonably normal values

Open
#3,377 1 comment 0 reactions 1 assignee View on GitHub

@SteveBronder is already working on this.

Since Aug 28, 2026.

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

Description

Dear all,

I am sorry for giving reference to Claude AI in advance, but it was flagged by it recently.

transformed data { real y = 0.865169; }
generated quantities {
  real lccdf = beta_lccdf(y | 1, 19);   //   -inf
  real truth = 19 * log1m(y);           //  -38.0709
}

Analytically that's beta_lccdf(y | 1, 19) = 19·log1m(x) = −38.07, entirely finite. Stan evaluates it as log(1 − inc_beta(...)), and (1−0.865)^19 = 3e-17 vanishes against 1.0 in double precision, so it returns log(0), which leads to initialization error.

Technically, I have also had similar problems working with log_diff_exp for _lcdf. So I replaced it with log(CDF1 - CDF2) and it worked quite fine.

Sorry if I disturbed you without a good reason in advance.

Best wishes,
Andrei

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.