### Question:
ExponentialVertex extends VertexImpl<DoubleTensor, DoubleVertex> implements DoubleVertex, Differentiable, ProbabilisticDouble, SamplableWithManyScalars<DoubleTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape()); final DoublePlaceholderVertex ratePlaceholder = new DoublePlaceholderVertex(rate.getShape()); return LogProbGraph.builder() .input(this, xPlaceholder) .input(rate, ratePlaceholder) .logProbOutput(Exponential.logProbOutput(xPlaceholder, ratePlaceholder)) .build(); } ExponentialVertex(@LoadShape long[] tensorShape,
                             @LoadVertexParam(RATE_NAME) Vertex<DoubleTensor, ?> rate); @ExportVertexToPythonBindings  ExponentialVertex(Vertex<DoubleTensor, ?> rate);  ExponentialVertex(double rate); @SaveVertexParam(RATE_NAME) DoubleVertex getRate(); @Override double logProb(DoubleTensor value); @Override LogProbGraph logProbGraph(); @Override Map<Vertex, DoubleTensor> dLogProb(DoubleTensor value, Set<? extends Vertex> withRespectTo); @Override DoubleTensor sampleWithShape(long[] shape, KeanuRandom random);  }### Answer:
@Test public void logProbGraphIsNegInfWhereXLessThanOne() { DoubleVertex rate = ConstantVertex.of(DoubleTensor.scalar(1.0)); ExponentialVertex tensorExponentialVertex = new ExponentialVertex(rate); LogProbGraph logProbGraph = tensorExponentialVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, rate, rate.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorExponentialVertex, DoubleTensor.create(1., -2.)); DoubleTensor expected = DoubleTensor.create(-1., Double.NEGATIVE_INFINITY); LogProbGraphContract.equalTensor(logProbGraph, expected); }
@Test public void logProbGraphMatchesKnownLogDensityOfScalar() { DoubleVertex rate = ConstantVertex.of(1.5); ExponentialVertex tensorExponentialVertex = new ExponentialVertex(rate); LogProbGraph logProbGraph = tensorExponentialVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, rate, rate.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorExponentialVertex, DoubleTensor.scalar(2.0)); ExponentialDistribution distribution = new ExponentialDistribution(1.5); double expectedDensity = distribution.logDensity(2.0); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex rate = ConstantVertex.of(1.0, 1.0); ExponentialVertex tensorExponentialVertex = new ExponentialVertex(rate); LogProbGraph logProbGraph = tensorExponentialVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, rate, rate.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorExponentialVertex, DoubleTensor.create(0.25, 0.75)); ExponentialDistribution distribution = new ExponentialDistribution(1.0); double expectedDensity = distribution.logDensity(0.25) + distribution.logDensity(0.75); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }