stan-dev / stan-dev/docs

Phi_approx is not as robust in the tails as normal_lcdf

Open
#352 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
43
Forks
133
Avg merge
11h 32m
Merged PRs (30d)
4

Description

I believe this is a docs issue with the normal distribution. The documentation at
https://mc-stan.org/docs/2_26/functions-reference/normal-distribution.html#normal-distribution says that Phi_approx is more robust in the tails. However, inspecting this shows that using normal_lcdf is actually more robust than Phi_approx.

Description:

Describe the issue as clearly as possible.

generated quantities {
  vector[3] x;
  vector[3] y;
  real w;
  real z;
  real a;
  
  x[1] = normal_lcdf(8 | 0, 1);
  x[2] = normal_lcdf(9 | 0, 1);
  x[3] = normal_lcdf(10 | 0, 1);
  
  y[1] = log(Phi_approx(8));
  y[2] = log(Phi_approx(9));
  y[3] = log(Phi_approx(10));
  
  w = log_diff_exp(y[3], y[2]);
  z = log_diff_exp(x[3], x[2]);
  a = log(Phi_approx(10) - Phi_approx(9));
}

If I check out

> out$summary(c("w", "z", "a"))
# A tibble: 3 x 10
  variable   mean median    sd   mad     q5    q95  rhat ess_bulk ess_tail
  <chr>     <dbl>  <dbl> <dbl> <dbl>  <dbl>  <dbl> <dbl>    <dbl>    <dbl>
1 w        -Inf   -Inf     NaN    NA -Inf   -Inf      NA       NA       NA
2 z         -43.6  -43.6     0     0  -43.6  -43.6    NA       NA       NA
3 a        -Inf   -Inf     NaN    NA -Inf   -Inf      NA       NA       NA

Looking at

 for (i in 1:40) {
    b[i] = normal_lcdf(i | 0, 1);
    c[i] = log(Phi_approx(i));
}

Shows that the normal_lcdf is more robust

Screen Shot 2021-04-13 at 8 31 37 AM Screen Shot 2021-04-13 at 8 31 53 AM

Contributor guide

No contributing guide indexed for this repository

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 the linked normal-distribution documentation page and compare its Phi_approx tail-robustness statement with the supplied Stan example and results. Update the documentation so the claim matches the observed behavior, then verify the rendered wording on the normal-distribution page.

Written by the indexing model from the issue text.

Assessment

Tech stack
tex
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.