Permalink
Browse files

Update master

  • Loading branch information...
1 parent 52bed4b commit 30f74b2d7391684a3acc40c632404c20a260c3af @tmalaska tmalaska committed Jul 15, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/main/java/com/cloudera/science/pig/EBCI.java
View
16 src/main/java/com/cloudera/science/pig/EBCI.java
@@ -19,6 +19,7 @@
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.MathRuntimeException;
import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction;
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.analysis.integration.SimpsonIntegrator;
@@ -72,6 +73,10 @@ public double value(double lambda) throws FunctionEvaluationException {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
+ } catch (Exception e)
+ {
+
+ throw new RuntimeException("lambda-" + lambda,e);
}
return Double.POSITIVE_INFINITY;
}
@@ -95,6 +100,9 @@ public EBCI(String target, String alpha1, String beta1,
Double.valueOf(alpha2), Double.valueOf(beta2), Double.valueOf(p));
}
+
+
+
public EBCI(double target, double alpha1, double beta1,
double alpha2, double beta2, double p) {
this.target = target;
@@ -111,12 +119,20 @@ public double eval(int n, double e) {
GammaDistribution g2 = new GammaDistributionImpl(alpha2 + n, beta2 + e);
PiFunction pi = new PiFunction(q.eval(n, e), g1, g2);
PiFunctionIntegral ipi = new PiFunctionIntegral(pi, target);
+
+
+
try {
return (new BrentSolver()).solve(ipi, 0.0, 10.0, 0.01);
} catch (ConvergenceException e1) {
e1.printStackTrace();
} catch (FunctionEvaluationException e1) {
e1.printStackTrace();
+ } catch (RuntimeException e1)
+ {
+ //MathRuntimeException function values at endpoints do not have different signs
+ e1.printStackTrace();
+
}
return -1.0;
}

0 comments on commit 30f74b2

Please sign in to comment.