Skip to content

Commit

Permalink
set a minial epsilon proba values for probability of intervals for re…
Browse files Browse the repository at this point in the history
…al model: Gaussian and Weibull #3
  • Loading branch information
Quentin62 committed Oct 16, 2020
1 parent 915b53a commit f082175
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
17 changes: 15 additions & 2 deletions MixtComp/src/lib/Mixture/Simple/Gaussian/GaussianLikelihood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ Real GaussianLikelihood::lnObservedProbability(int i, int k) const {
Real supCdf = normal_.cdf(supBound,
mean,
sd);
logProba = std::log(supCdf - infCdf);

Real proba = supCdf - infCdf;
if(proba < epsilonProba)
proba = epsilonProba;

logProba = std::log(proba);
}
break;

Expand All @@ -80,6 +85,10 @@ Real GaussianLikelihood::lnObservedProbability(int i, int k) const {
Real supCdf = normal_.cdf(supBound,
mean,
sd);

if(supCdf < epsilonProba)
supCdf = epsilonProba;

logProba = std::log(supCdf);
}
break;
Expand All @@ -89,7 +98,11 @@ Real GaussianLikelihood::lnObservedProbability(int i, int k) const {
Real infCdf = normal_.cdf(infBound,
mean,
sd);
logProba = std::log(1. - infCdf);
Real proba = 1. - infCdf;
if(proba < epsilonProba)
proba = epsilonProba;

logProba = std::log(proba);
}
break;

Expand Down
13 changes: 11 additions & 2 deletions MixtComp/src/lib/Mixture/Simple/Weibull/WeibullLikelihood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ Real WeibullLikelihood::lnObservedProbability(Index i, Index k) const {
case missingRUIntervals_: {
Real infBound = augData_.misData_(i).second[0];
Real infCdf = weibull_.cdf(infBound, kParam, lambda);
logProba = std::log(1.0 - infCdf);
Real proba = 1. - infCdf;
if(proba < epsilonProba)
proba = epsilonProba;

logProba = std::log(proba);
}
break;

Expand All @@ -67,7 +71,12 @@ Real WeibullLikelihood::lnObservedProbability(Index i, Index k) const {
Real supBound = augData_.misData_(i).second[1];
Real infCdf = weibull_.cdf(infBound, kParam, lambda);
Real supCdf = weibull_.cdf(supBound, kParam, lambda);
logProba = std::log(supCdf - infCdf);

Real proba = supCdf - infCdf;
if(proba < epsilonProba)
proba = epsilonProba;

logProba = std::log(proba);
}
break;

Expand Down
2 changes: 2 additions & 0 deletions MixtComp/src/lib/Various/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const Real epsilon = 1.e-8;
const std::string epsilonStr = "1.e-8";
const Real logEpsilon = std::log(epsilon);

const Real epsilonProba = std::numeric_limits<Real>::epsilon();

const int minModality = 1;
const int minIndex = 1;
const Real pi = boost::math::constants::pi<Real>();
Expand Down
2 changes: 2 additions & 0 deletions MixtComp/src/lib/Various/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern const int nbSamplingAttempts; // number of sampling attempts, when not en
extern const Real epsilon; // very small value of real to check for near zero values
extern const std::string epsilonStr; // previous value, in scientific notation
extern const Real logEpsilon; // log of very small value
extern const Real epsilonProba; // very small value of real to check for near zero values for probabilities


extern const int minModality; // minimal modality for categorical models (for example, 0-based or 1-based numbering)
extern const int minIndex;
Expand Down

0 comments on commit f082175

Please sign in to comment.