Incorrect behaviour of CCDFs when there is a negative random variable
Open
@bob-carpenter is already working on this.
Since Apr 3, 2017.
bug
good first issue
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
From @randommm on November 20, 2014 1:55
The following program:
transformed data {
int y[2];
y[1] <- 0;
y[2] <- 1;
print(poisson_ccdf_log(0, 5));
print(poisson_ccdf_log(1, 5));
print(poisson_ccdf_log(y, 5));
}
parameters {
real any;
}
model {
any ~ normal(0, 1);
}
Outputs:
-0.00676075
-0.0412676
-0.0480283
(the last number is the sum of the first two as expected)
However, the following program:
transformed data {
int y[2];
y[1] <- -1;
y[2] <- 1;
print(poisson_ccdf_log(-1, 5));
print(poisson_ccdf_log(1, 5));
print(poisson_ccdf_log(y, 5));
}
parameters {
real any;
}
model {
any ~ normal(0, 1);
}
Outputs:
0
-0.0412676
0
Which doesn't make sense: the last number should have been -0.0412676 too.
The way the CCDFs are currently designed makes them ignore everything when there is a negative random variable inside the vector of random variables:
// Explicit return for extreme values
// The gradients are technically ill-defined, but treated as neg infinity
for (size_t i = 0; i < stan::length(n); i++) {
if (value_of(n_vec[i]) < 0)
return operands_and_partials.to_var(0.0);
}
Copied from original issue: stan-dev/stan#1142
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.