Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[On hold] New formulas for derivatives of neg_binomial_lpmf after alpha cutoff #1579

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Jenkins] auto-formatting by clang-format version 5.0.0-3~16.04.1 (ta…
…gs/RELEASE_500/final)
  • Loading branch information
stan-buildbot committed Jan 3, 2020
commit 095974e718e145215f3fad55fe4c5f6ee03a4f59
6 changes: 3 additions & 3 deletions stan/math/prim/prob/neg_binomial_lpmf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ return_type_t<T_shape, T_inv_scale> neg_binomial_lpmf(const T_n& n,
if (alpha_vec[i] > internal::neg_binomial_alpha_cutoff) {
// reduces numerically to Poisson
// The derivatives are obtained via Taylor series at alpha -> Inf
// via Mathematica as:
// nb[n_,alpha_,beta_]:= LogGamma[n + alpha] - LogGamma[n + 1] -
// via Mathematica as:
// nb[n_,alpha_,beta_]:= LogGamma[n + alpha] - LogGamma[n + 1] -
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should assume the readers of comments understand mathematica. So this should be put in Stan notation or just eliminated. I couldn't understand what LogGamma is or Log or D. If these comments stay, the functions used need to be explained.

// LogGamma[alpha ] + alpha * Log[beta/ (1 + beta)] - n * Log[1 + beta];
// nbdalpha[n_,alpha_,beta_]= D[nb[n, alpha, beta],alpha];
// nbdbeta[n_,alpha_,beta_]= D[nb[n, alpha, beta],beta];
Expand All @@ -127,7 +127,7 @@ return_type_t<T_shape, T_inv_scale> neg_binomial_lpmf(const T_n& n,

if (!is_constant_all<T_shape>::value) {
ops_partials.edge1_.partials_[i]
+= n_vec[i] / value_of(alpha_vec[i]) + log_beta_m_log1p_beta[i];
+= n_vec[i] / value_of(alpha_vec[i]) + log_beta_m_log1p_beta[i];
}
if (!is_constant_all<T_inv_scale>::value) {
ops_partials.edge2_.partials_[i]
Expand Down
Loading