Skip to content

Commit

Permalink
Improve numerical issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yxu927 committed Jul 25, 2024
1 parent d224eca commit 6c83bf4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ public double getPopSize(double t) {
@Override
public double getIntensity(double t) {
if (t == 0) return 0;
UnivariateFunction function = time -> 1 / getPopSize(time);
UnivariateFunction function = time -> 1 / Math.max(getPopSize(time), 1e-20);
IterativeLegendreGaussIntegrator integrator = new IterativeLegendreGaussIntegrator(5, 1.0e-12, 1.0e-8, 2, 10000);
double intensity = 0;
try {
return integrator.integrate(Integer.MAX_VALUE, function, 0, t);
intensity = integrator.integrate(100000, function, 0, t);
} catch (TooManyEvaluationsException ex) {
System.err.println("Numerical Integration Error: " + ex.getMessage());
return 0;
return intensity;
}
return intensity;
}


@Override
public double getInverseIntensity(double x) {
return 0;
Expand Down

0 comments on commit 6c83bf4

Please sign in to comment.