List of usage examples for java.lang Double POSITIVE_INFINITY
double POSITIVE_INFINITY
To view the source code for java.lang Double POSITIVE_INFINITY.
Click Source Link
From source file:com.opengamma.analytics.math.statistics.distribution.BivariateNormalDistribution.java
/** * @param x The parameters for the function, $(x, y, \rho$, with $-1 \geq \rho \geq 1$, not null * @return The cdf//from ww w. j ava2 s .co m */ @Override public double getCDF(final double[] x) { Validate.notNull(x); Validate.isTrue(x.length == 3, "Need a, b and rho values"); Validate.isTrue(x[2] >= -1 && x[2] <= 1, "Correlation must be >= -1 and <= 1"); final double a = x[0]; double b = x[1]; final double rho = x[2]; if (a == Double.POSITIVE_INFINITY || b == Double.POSITIVE_INFINITY) { return 1; } if (a == Double.NEGATIVE_INFINITY || b == Double.NEGATIVE_INFINITY) { return 0; } final double sumSq = (a * a + b * b) / 2.; double rho1, rho2, rho3, ab, absDiff, h5, c, d, mult = 0, rho3Sq, eab, e, result; if (Math.abs(rho) >= 0.7) { rho1 = 1 - rho * rho; rho2 = Math.sqrt(rho1); if (rho < 0) { b *= -1; } ab = a * b; eab = Math.exp(-ab / 2.); if (Math.abs(rho) < 1) { absDiff = Math.abs(a - b); h5 = absDiff * absDiff / 2.; absDiff = absDiff / rho2; c = 0.5 - ab / 8.; d = 3. - 2. * c * h5; mult = 0.13298076 * absDiff * d * (1 - NORMAL.getCDF(absDiff)) - Math.exp(-h5 / rho1) * (d + c * rho1) * 0.053051647; for (int i = 0; i < 5; i++) { rho3 = rho2 * X[i]; rho3Sq = rho3 * rho3; rho1 = Math.sqrt(1 - rho3Sq); if (eab == 0) { e = 0; } else { e = Math.exp(-ab / (1 + rho1)) / rho1 / eab; } mult = mult - Y[i] * Math.exp(-h5 / rho3Sq) * (e - 1 - c * rho3Sq); } } result = mult * rho2 * eab + NORMAL.getCDF(Math.min(a, b)); if (rho < 0) { result = NORMAL.getCDF(a) - result; } return result; } ab = a * b; if (rho != 0) { for (int i = 0; i < 5; i++) { rho3 = rho * X[i]; rho1 = 1 - rho3 * rho3; mult = mult + Y[i] * Math.exp((rho3 * ab - sumSq) / rho1) / Math.sqrt(rho1); } } return NORMAL.getCDF(a) * NORMAL.getCDF(b) + rho * mult; }
From source file:ml.shifu.shifu.core.binning.obj.NumBinInfo.java
public static List<NumBinInfo> constructNumBinfo(String binsData, char fieldSeparator) { List<NumBinInfo> binInfos = new ArrayList<NumBinInfo>(); List<Double> thresholds = new ArrayList<Double>(); thresholds.add(Double.NEGATIVE_INFINITY); if (StringUtils.isNotBlank(binsData)) { String[] fields = StringUtils.split(binsData, fieldSeparator); if (fields != null) { for (String field : fields) { Double val = null; try { val = Double.valueOf(field); thresholds.add(val); } catch (Exception e) { // skip illegal double }/*from w ww. j a v a 2 s.c om*/ } } } thresholds.add(Double.POSITIVE_INFINITY); Collections.sort(thresholds); for (int i = 0; i < thresholds.size() - 1; i++) { binInfos.add(new NumBinInfo(thresholds.get(i), thresholds.get(i + 1))); } return binInfos; }
From source file:jurls.core.approximation.WeightedInterpolationFunction.java
public WeightedInterpolationFunction(int numInputs, int numPoints, double power) { this.numPoints = numPoints; this.power = power; minInput.set(Double.POSITIVE_INFINITY); maxInput.set(Double.NEGATIVE_INFINITY); points = new Point[numPoints]; for (int i = 0; i < numPoints; ++i) { points[i] = new Point(); }//www . j av a 2 s .c o m }
From source file:beast.inference.distribution.GammaDistributionModel.java
/** * Construct a constant mutation rate model. *///from ww w .j a v a 2 s.co m public GammaDistributionModel(Variable<Double> shape, Variable<Double> scale) { super(GAMMA_DISTRIBUTION_MODEL); this.shape = shape; this.scale = scale; addVariable(shape); shape.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); if (scale != null) { addVariable(scale); scale.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); } }
From source file:eu.crisis_economics.abm.contracts.DepositAccount.java
public DepositAccount(final DepositHolder iDepositHolder, final Depositor iDepositor, final double amount, final double interestRate) { // super(depositHolder, depositor); super(Double.POSITIVE_INFINITY); depositHolder = iDepositHolder;//from w w w . j a v a 2 s. c o m depositor = iDepositor; this.presentValue = new FixedValueContract(Double.POSITIVE_INFINITY, interestRate, 0., 0.); this.deposit(amount); this.isTerminated = false; depositHolder.addLiability(this); depositor.addAsset(this); this.scheduledStepMethod = Simulation.once(this, "step", NamedEventOrderings.DEPOSIT_PAYMENT); }
From source file:jeans.math.SingleStat.java
public SingleStat() { m_Min = Double.POSITIVE_INFINITY; m_Max = Double.NEGATIVE_INFINITY; }
From source file:dr.inference.distribution.InverseGammaDistributionModel.java
/** * Construct a constant mutation rate model. *//*from www. j a v a 2s. c om*/ public InverseGammaDistributionModel(Variable<Double> shape, Variable<Double> scale) { super(INVERSE_GAMMA_DISTRIBUTION_MODEL); this.shape = shape; this.scale = scale; addVariable(shape); shape.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); addVariable(scale); scale.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); }
From source file:com.squarespace.template.plugins.platform.CommerceUtilsTest.java
@Test public void testGetTotalStockRemaining() { Map<String, JsonNode> jsonMap = loadJson(CommerceUtilsTest.class, "get-total-stock-remaining.json"); JsonNode item = jsonMap.get("getTotalStock-unlimited-physical"); assertEquals(getTotalStockRemaining(item), Double.POSITIVE_INFINITY); item = jsonMap.get("getTotalStock-digital"); assertEquals(getTotalStockRemaining(item), Double.POSITIVE_INFINITY); item = jsonMap.get("getTotalStock-six-service"); assertEquals(getTotalStockRemaining(item), 6.0); item = jsonMap.get("getTotalStock-0-physical"); assertEquals(getTotalStockRemaining(item), 0.0); item = jsonMap.get("getTotalStock-0-physical-2"); assertEquals(getTotalStockRemaining(item), 0.0); item = jsonMap.get("getTotalStock-unknown"); assertEquals(getTotalStockRemaining(item), 0.0); }
From source file:com.vsthost.rnd.jdeoptim.evolution.Population.java
/** * Instantiates a population with the data consumed. * * @param data The data which the population is going to be initialized with. *//*from w ww. j a v a2 s . co m*/ public Population(double[][] data) { // Save the data field: this.data = data; // Get the size and save it: this.size = this.data.length; // Get the dimension and save it: this.dimension = this.size > 0 ? this.data[0].length : 0; // Initialize the scores: this.setScores(Double.POSITIVE_INFINITY); }
From source file:jtrace.object.Cube.java
@Override public double getFirstCollisionObjectFrame(Ray ray) { // Cube edges and vertices are the intersections of 6 planes. // Need to find points of intersection with each of these planes. double alpha = Double.POSITIVE_INFINITY; Ray collisionNormal = new Ray(); for (int i = 0; i < 6; i++) { double thisAlpha = normals[i].direction.dotProduct(normals[i].origin.subtract(ray.origin)) / normals[i].direction.dotProduct(ray.direction); if (thisAlpha <= 0) continue; Vector3D collisionLocation = ray.origin.add(thisAlpha, ray.direction); Vector3D delta = collisionLocation.subtract(normals[i].origin); if (Math.abs(delta.getX()) > 0.5 || Math.abs(delta.getY()) > 0.5 || Math.abs(delta.getZ()) > 0.5) { continue; }/*from ww w .j a v a2s. co m*/ if (thisAlpha < alpha) { alpha = thisAlpha; collisionNormal.origin = collisionLocation; collisionNormal.direction = normals[i].direction; } } if (alpha < Double.POSITIVE_INFINITY) { incidentRay = ray; normalRay = collisionNormal; } return alpha; }