Skip to content

Commit

Permalink
Manage the case when lambda = 0 for Poisson and there are some missin…
Browse files Browse the repository at this point in the history
…g intervals
  • Loading branch information
Quentin62 committed Oct 16, 2020
1 parent 04148a4 commit 915b53a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
10 changes: 0 additions & 10 deletions MixtComp/src/lib/Mixture/Simple/Poisson/Poisson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ std::string Poisson::mStep(const Vector<std::set<Index>>& classInd) {
}

param_(k) = sumClass / Real(classInd(k).size());

if (param_(k) < epsilon) {
warnLog +=
"Poisson variables must have a minimum mean of "
+ epsilonStr
+ " in each class. It is not the case in class: "
+ std::to_string(k)
+ "."
+ eol;
}
}

return warnLog;
Expand Down
27 changes: 19 additions & 8 deletions MixtComp/src/lib/Mixture/Simple/Poisson/PoissonStatistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ Real PoissonStatistic::lpdf(int x, Real lambda) const {
}

Real PoissonStatistic::cdf(int x, Real lambda) const {
boost::math::poisson pois(lambda);
Real proba = boost::math::cdf(pois, x);
return proba;
if (0.0 < lambda) {
boost::math::poisson pois(lambda);
Real proba = boost::math::cdf(pois, x);

return proba;
} else {
return 1.0;
}
}


Expand Down Expand Up @@ -103,11 +108,17 @@ int PoissonStatistic::quantile(Real lambda, Real p) const {
* https://www.boost.org/doc/libs/1_69_0/libs/math/doc/html/math_toolkit/pol_tutorial/understand_dis_quant.html
*
*/
boost::math::poisson_distribution<
double,
boost::math::policies::policy<boost::math::policies::discrete_quantile<boost::math::policies::integer_round_up> > > pois(lambda);
int q = boost::math::quantile(pois, p);
return q;
if (0.0 < lambda)
{
boost::math::poisson_distribution<
double,
boost::math::policies::policy<boost::math::policies::discrete_quantile<boost::math::policies::integer_round_up> > > pois(lambda);
int q = boost::math::quantile(pois, p);
return q;
} else {
return 0.0;
}

}

int PoissonStatistic::quantileIB(Real lambda, int infBound, Real p) const {
Expand Down
4 changes: 2 additions & 2 deletions RMixtCompIO/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: RMixtCompIO
Type: Package
Title: Mixture Models with Heterogeneous and (Partially) Missing Data
Version: 4.0.6
Date: 2020-10-15
Date: 2020-10-16
Authors@R: c(person("Vincent", "Kubicki", role = "aut"),
person("Christophe", "Biernacki", role = "aut"),
person("Quentin", "Grimonprez", role = c("aut", "cre"), email = "[email protected]"),
Expand All @@ -22,5 +22,5 @@ BugReports: https://github.com/modal-inria/MixtComp/issues
Imports: Rcpp, doParallel, foreach
Suggests: Rmixmod, blockcluster, testthat, RInside, xml2
LinkingTo: Rcpp, RcppEigen, BH
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
Encoding: UTF-8
2 changes: 1 addition & 1 deletion RMixtCompIO/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ v 4.0.6
- catch error "XXX object does not exit."
- rename some C++ classes and files
- remove useless files
- detect when the Poisson's parameter is estimated at 0
- Manage the case when lambda = 0 for Poisson and there are some missing intervals

v4.0.5 2020-06-15
- bug correction when z_class is in data but not in the model
Expand Down

0 comments on commit 915b53a

Please sign in to comment.