RiskRatio { public static RiskRatioResult compute(Number exposedInlierCount, Number exposedOutlierCount, Number totalInliers, Number totalOutliers) { if(exposedInlierCount == null) { exposedInlierCount = 0.; } if(exposedOutlierCount == null) { exposedOutlierCount = 0.; } if(totalInliers == null) { totalInliers = 0.; } if(totalOutliers == null) { totalOutliers = 0.; } return computeDouble(exposedInlierCount.doubleValue(), exposedOutlierCount.doubleValue(), totalInliers.doubleValue(), totalOutliers.doubleValue()); }  static RiskRatioResult compute(Number exposedInlierCount,
                                 Number exposedOutlierCount,
                                 Number totalInliers,
                                 Number totalOutliers);  }
@Test public void testRatio() { assertEquals(1.0, RiskRatio.compute(10, 10, 100, 100).get(), 0.01); assertEquals(6., RiskRatio.compute(10, 10, 1000, 100).get(), 0.01); assertEquals(900.082, RiskRatio.compute(10, 99, 1000, 100).get(), 0.01); }
@Test public void testRatioBoundaryConditions() { assertEquals(0, RiskRatio.compute(0, 0, 100, 100).get(), 0); assertEquals(0, RiskRatio.compute(100, 100, 100, 100).get(), 0); assertEquals(Double.POSITIVE_INFINITY, RiskRatio.compute(0, 100, 100, 100).get(), 0); assertEquals(Double.POSITIVE_INFINITY, RiskRatio.compute(null, 100, 100, 100).get(), 0); assertEquals(0, RiskRatio.compute(100, 0, 1000, 100).get(), 0); assertEquals(0, RiskRatio.compute(100, null, 1000, 100).get(), 0); assertEquals(0, RiskRatio.compute(null, null, null, null).get(), 0); }