stan-dev / stan-dev/stan

truncation out-of-bounds in model should throw

Open
#2,053 0 comments 0 reactions 1 assignee View on GitHub

@bob-carpenter is already working on this.

Since Sep 3, 2016.

feature language
Dominant language
C++
Stars
2.8k
Forks
388
Avg merge
2d 17h
Merged PRs (30d)
15

Description

Summary:

As pointed out by @bgoodri on stan-dev list, truncation syntax is generating

        if (y < 1) lp_accum__.add(-std::numeric_limits<double>::infinity());
        else lp_accum__.add(-poisson_ccdf_log(1, rate));

Instead it should be throwing std::domain_error with a meaningful message.

Also from @bgoodri:

For

y ~ normal(mu, sigma) T[1,];

then if y < 1, then I think it should exit but if y == 1, then it should throw an non-fatal exception. It is possible that the user wrote

parameters {
  real<lower=1> y;
  ...
}

and y just underflows to 1.

  • fix by generating call to appropriate err functions in stan::math with appropriate bounds
Reproducible Steps:

Use truncation with out of bounds.

Current Output:

Nothing---just keeps going and get failure due to -infinity log density.

Expected Output:

Appropriate warning message.

Current Version:

v2.11.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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.