/** {@inheritDoc} */ public double density(double x) { return FastMath.exp(logDensity(x)); }
/** {@inheritDoc} */ public double density(double x) { return Math.exp(logDensity(x)); }
/** {@inheritDoc} */ public double density(double x) { return FastMath.exp(logDensity(x)); }
private void testLogPdfAtGivenDegreesOfFreedom(int v) { TDistribution apache = new TDistribution(v); StudentTVertex studentT = new StudentTVertex(v); for (double t = -4.5; t <= 4.5; t += 0.5) { double expected = apache.logDensity(t); double actual = studentT.logPdf(t); assertEquals(expected, actual, DELTA); } }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { IntegerVertex v = ConstantVertex.of(1, 1); StudentTVertex studentT = new StudentTVertex(v); LogProbGraph logProbGraph = studentT.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, v, v.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, studentT, DoubleTensor.create(-4.5, 4.5)); TDistribution distribution = new TDistribution(1); double expectedDensity = distribution.logDensity(-4.5) + distribution.logDensity(4.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfScalar() { IntegerVertex v = ConstantVertex.of(1); StudentTVertex studentT = new StudentTVertex(v); LogProbGraph logProbGraph = studentT.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, v, v.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, studentT, DoubleTensor.scalar(-4.5)); TDistribution distribution = new TDistribution(1); double expectedDensity = distribution.logDensity(-4.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }