Skip to content

Commit 1d0ce81

Browse files
authored
Merge pull request #3036 from venpopov/feature/issue-3035-von_mises_stability
Improve numerical stability of von_mises_lpdf
2 parents e8ab249 + 76dea25 commit 1d0ce81

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

stan/math/prim/prob/von_mises_lpdf.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ return_type_t<T_y, T_loc, T_scale> von_mises_lpdf(T_y const& y, T_loc const& mu,
8181
if (!is_constant_all<T_scale>::value) {
8282
edge<2>(ops_partials).partials_
8383
= cos_mu_minus_y
84-
- modified_bessel_first_kind(1, kappa_val)
85-
/ modified_bessel_first_kind(0, kappa_val);
84+
- exp(log_modified_bessel_first_kind(1, kappa_val)
85+
- log_modified_bessel_first_kind(0, kappa_val));
8686
}
8787

8888
return ops_partials.build(logp);

0 commit comments

Comments
 (0)