@Test public void testSamplerHelper1() { final double tol = 1e-12; final double[] testValues = { FastMath.nextUp(-1.), -1e-1, -1e-2, -1e-3, -1e-4, -1e-5, -1e-6, -1e-7, -1e-8, -1e-9, -1e-10, -1e-11, 0., 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0 }; for (final double testValue : testValues) { final double expected = FastMath.log1p(testValue); TestUtils.assertRelativelyEquals( expected, ZipfRejectionInversionSampler.helper1(testValue) * testValue, tol); } }
@Test public void testSamplerHelper1Minus1() { Assert.assertEquals(Double.POSITIVE_INFINITY, ZipfRejectionInversionSampler.helper1(-1d), 0d); }