Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
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
6 changes: 4 additions & 2 deletions MixtComp/src/lib/Various/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ const std::string eol = "\n";

const int nbSamplingAttempts = 10000;

const Real epsilon = 1.e-8;
const std::string epsilonStr = "1.e-8";
const Real epsilon = 1.e-10;
const std::string epsilonStr = "1.e-10";
const Real logEpsilon = std::log(epsilon);

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

#if defined MINMODALITY
const int minModality = MINMODALITY;
#else
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
4 changes: 2 additions & 2 deletions MixtComp/src/utest/Functional/UTestFuncCSComputation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ TEST(FuncCSComputation, regressionNoNoise) {

regression(design, y, betaEstimated, sdEstimated);

ASSERT_EQ(true, betaEstimated.isApprox(beta, epsilon));
ASSERT_NEAR(0., sdEstimated, epsilon);
EXPECT_EQ(true, betaEstimated.isApprox(beta, 1e-8));
EXPECT_NEAR(0., sdEstimated, 1e-8);
}

TEST(FuncCSComputation, regressionNoise) {
Expand Down