List of usage examples for jdk.nashorn.internal.objects Global Infinity
double Infinity
To view the source code for jdk.nashorn.internal.objects Global Infinity.
Click Source Link
From source file:HillClimbing.HCIndividual.java
public void evolve() { Function f = ((HCPopulation) this.getPopulation()).getFunction(); double currentPoint[] = this.getX(); double stepSize[] = new double[currentPoint.length]; Arrays.fill(stepSize, random.nextGaussian() + 1); double acc = random.nextGaussian() + 1.2; double candidate[] = new double[5]; candidate[0] = -acc;/*from ww w . j a va2 s . c o m*/ candidate[1] = -1 / acc; candidate[2] = 0; candidate[3] = 1 / acc; candidate[4] = acc; double before = f.calculate(this.getX()); for (int i = 0; i < currentPoint.length; i++) { int best = 1; double bestScore = Global.Infinity; for (int j = 0; j < 4; j++) { currentPoint[i] = currentPoint[i] + stepSize[i] * candidate[j]; double temp = f.calculate(currentPoint); currentPoint[i] = currentPoint[i] - stepSize[i] * candidate[j]; if (temp < bestScore) { bestScore = temp; best = j; } } if (candidate[best] == 0) { stepSize[i] = stepSize[i] / acc; } else { currentPoint[i] = currentPoint[i] + stepSize[i] * candidate[best]; stepSize[i] = stepSize[i] * candidate[best]; // accelerate } } if (f.calculate(currentPoint) < before) this.setX(currentPoint); }
From source file:MathExt.Ext.java
private static double gamma(double z) { if (z > 150) { return Global.Infinity; }//ww w . ja v a 2 s .co m if (z < 0.5) { return Math.PI / (Math.sin(Math.PI * z) * gamma(1 - z)); } else { z -= 1; double x = C[0]; for (int i = 1; i < g + 2; i++) x += C[i] / (z + i); double t = z + g + 0.5; return Math.sqrt(2 * Math.PI) * Math.pow(t, (z + 0.5)) * Math.exp(-t) * x; } }