numerical stability tips

33 views
Skip to first unread message

Alp Kucukelbir

unread,
Aug 11, 2015, 11:14:45 AM8/11/15
to stan development mailing list, scg...@stanford.edu
hi folks,

i've been communicating with sharad goel, who wants to use the function below in a Stan program.

functions {
// mean of beta(a,b) conditioned on being larger than x
real beta_conditional_mean(real x, real a, real b) {
return (1 - beta_cdf(x, a+1, b)) / (1 - beta_cdf(x, a, b)) * a / (a+b);
}
}

any tips to make this more numerically stable? i think i'm mainly worried about when a and b are small, but i may be missing something here.

cheers
alp

Ben Goodrich

unread,
Aug 11, 2015, 10:51:02 PM8/11/15
to stan development mailing list, scg...@stanford.edu

Using the beta_ccdf() function may be more stable than 1 - beta_cdf().

Ben
Reply all
Reply to author
Forward
0 new messages