List of usage examples for org.apache.commons.math3.exception TooManyEvaluationsException TooManyEvaluationsException
public TooManyEvaluationsException(Number max)
From source file:gdsc.smlm.ij.plugins.EMGainAnalysis.java
private MultivariateFunction getFunction(final int[] limits, final double[] y, final int max, final int maxEval) { MultivariateFunction fun = new MultivariateFunction() { int eval = 0; public double value(double[] point) { IJ.showProgress(++eval, maxEval); if (Utils.isInterrupted()) throw new TooManyEvaluationsException(maxEval); // Compute the sum of squares between the two functions double photons = point[0]; double gain = point[1]; double noise = point[2]; int bias = (int) Math.round(point[3]); //System.out.printf("[%d] = %s\n", eval, Arrays.toString(point)); final double[] g = pdf(max, photons, gain, noise, bias); double ss = 0; for (int c = limits[0]; c <= limits[1]; c++) { final double d = g[c] - y[c]; ss += d * d;/* w ww. ja va 2 s . co m*/ } return ss; } }; return fun; }