### Question:
ExponentialDistribution extends AbstractContinuousDistribution { @Override public double density(double x) { final double logDensity = logDensity(x); return logDensity == Double.NEGATIVE_INFINITY ? 0 : Math.exp(logDensity); } ExponentialDistribution(double mean); @Override double density(double x); @Override double logDensity(double x); @Override double cumulativeProbability(double x); @Override double inverseCumulativeProbability(double p); @Override double getMean(); @Override double getVariance(); @Override double getSupportLowerBound(); @Override double getSupportUpperBound(); @Override boolean isSupportConnected(); @Override ContinuousDistribution.Sampler createSampler(final UniformRandomProvider rng);  }### Answer:
@Test void testDensity() { final ExponentialDistribution d1 = new ExponentialDistribution(1); Assertions.assertTrue(Precision.equals(0.0, d1.density(-1e-9), 1)); Assertions.assertTrue(Precision.equals(1.0, d1.density(0.0), 1)); Assertions.assertTrue(Precision.equals(0.0, d1.density(1000.0), 1)); Assertions.assertTrue(Precision.equals(Math.exp(-1), d1.density(1.0), 1)); Assertions.assertTrue(Precision.equals(Math.exp(-2), d1.density(2.0), 1)); final ExponentialDistribution d2 = new ExponentialDistribution(3); Assertions.assertTrue(Precision.equals(1 / 3.0, d2.density(0.0), 1)); Assertions.assertEquals(0.2388437702, d2.density(1.0), 1e-8); Assertions.assertEquals(0.1711390397, d2.density(2.0), 1e-8); }