FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Phi_approx is not as robust in the tails as normal_lcdf · Issue #352 · stan-dev/docs · GitHub

/ docs Public

Phi_approx is not as robust in the tails as normal_lcdf #352

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL