public void testOne() { final PossibilityArithmetic arith = arithmetic(); final double one = arith.one(); assertEquals(1.0, arith.poss2Prob(one)); assertEquals(0.0, arith.poss2Ln(one), 0.0); assertTrue(arith.isValidPoss(one)); assertEquals(one, arith.prob2Poss(1.0)); assertEquals(one, arith.ln2Poss(0.0)); }
public void testZero() { final PossibilityArithmetic arith = arithmetic(); final double zero = arith.zero(); assertEquals(0.0, arith.poss2Prob(zero)); assertEquals(Double.NEGATIVE_INFINITY, arith.poss2Ln(zero)); assertTrue(arith.isValidPoss(zero)); assertEquals(zero, arith.prob2Poss(0.0)); assertEquals(zero, arith.ln2Poss(Double.NEGATIVE_INFINITY)); }
private void checkPow( final PossibilityArithmetic arith, final double p1, final double p2, double tolerance) { final double p = Math.pow(p1, p2); final double s1 = arith.prob2Poss(p1); assertTrue(arith.isValidPoss(s1)); final double s = arith.pow(s1, p2); final double pp = arith.poss2Prob(s); assertEquals(p, pp, tolerance); }
private void checkDiv( final PossibilityArithmetic arith, final double p1, final double p2, double tolerance) { final double p = p1 / p2; final double s1 = arith.prob2Poss(p1); assertTrue(arith.isValidPoss(s1)); final double s2 = arith.prob2Poss(p2); assertTrue("" + s2, arith.isValidPoss(s2)); final double s = arith.divide(s1, s2); assertTrue(arith.isValidPoss(s)); final double pp = arith.poss2Prob(s); assertEquals(p, pp, tolerance); }
private void checkMult( final PossibilityArithmetic arith, final double p1, final double p2, double tolerance) { final double p = p1 * p2; final double s1 = arith.prob2Poss(p1); assertTrue(arith.isValidPoss(s1)); final double s2 = arith.prob2Poss(p2); assertTrue(arith.isValidPoss(s2)); final double s = arith.multiply(s1, s2); assertTrue(arith.isValidPoss(s)); final double pp = arith.poss2Prob(s); assertEquals(p, pp, tolerance); }