Skip to content

Commit

Permalink
Fix zero mass for NB
Browse files Browse the repository at this point in the history
  • Loading branch information
sparktseung committed Mar 29, 2021
1 parent 025fc46 commit bd24157
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/experts/discrete/negativebinomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ function EM_M_expert(d::NegativeBinomialExpert,

p_new = _negativebinomial_n_to_p(n_new, sum_term_zkz, sum_term_zkzy, penalty = penalty, pen_pararms_jk = pen_pararms_jk)

# Deal with zero mass
if (p_new^n_new > 0.999999) || (isnan(p_new^n_new))
p_new, n_new = d.p, d.n
end

return NegativeBinomialExpert(n_new, p_new)

end
Expand Down Expand Up @@ -272,6 +277,11 @@ function EM_M_expert_exact(d::NegativeBinomialExpert,

p_new = _negativebinomial_n_to_p(n_new, sum_term_zkz, sum_term_zkzy, penalty = penalty, pen_pararms_jk = pen_pararms_jk)

# Deal with zero mass
if (p_new^n_new > 0.999999) || (isnan(p_new^n_new))
p_new, n_new = d.p, d.n
end

return NegativeBinomialExpert(n_new, p_new)

end

0 comments on commit bd24157

Please sign in to comment.