### Question:
LaplaceVertex extends VertexImpl<DoubleTensor, DoubleVertex> implements DoubleVertex, Differentiable, ProbabilisticDouble, SamplableWithManyScalars<DoubleTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape()); final DoublePlaceholderVertex muPlaceholder = new DoublePlaceholderVertex(mu.getShape()); final DoublePlaceholderVertex betaPlaceholder = new DoublePlaceholderVertex(beta.getShape()); return LogProbGraph.builder() .input(this, xPlaceholder) .input(mu, muPlaceholder) .input(beta, betaPlaceholder) .logProbOutput(Laplace.logProbOutput(xPlaceholder, muPlaceholder, betaPlaceholder)) .build(); } LaplaceVertex(@LoadShape long[] tensorShape,
                         @LoadVertexParam(MU_NAME) Vertex<DoubleTensor, ?> mu,
                         @LoadVertexParam(BETA_NAME) Vertex<DoubleTensor, ?> beta);  LaplaceVertex(long[] shape, Vertex<DoubleTensor, ?> mu, double beta);  LaplaceVertex(long[] shape, double mu, Vertex<DoubleTensor, ?> beta);  LaplaceVertex(long[] shape, double mu, double beta); @ExportVertexToPythonBindings  LaplaceVertex(Vertex<DoubleTensor, ?> mu,
                         Vertex<DoubleTensor, ?> beta);  LaplaceVertex(Vertex<DoubleTensor, ?> mu, double beta);  LaplaceVertex(double mu, Vertex<DoubleTensor, ?> beta);  LaplaceVertex(double mu, double beta); @SaveVertexParam(MU_NAME) DoubleVertex getMu(); @SaveVertexParam(BETA_NAME) DoubleVertex getBeta(); @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 logProbGraphMatchesKnownLogDensityOfScalar() { DoubleVertex mu = ConstantVertex.of(0.5); DoubleVertex beta = ConstantVertex.of(1.); LaplaceVertex laplaceVertex = new LaplaceVertex(mu, beta); LogProbGraph logProbGraph = laplaceVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, mu, mu.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, laplaceVertex, DoubleTensor.scalar(0.5)); LaplaceDistribution distribution = new LaplaceDistribution(0.5, 1.); double expectedDensity = distribution.logDensity(0.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex mu = ConstantVertex.of(0., 0.); DoubleVertex beta = ConstantVertex.of(1., 1.); LaplaceVertex laplaceVertex = new LaplaceVertex(mu, beta); LogProbGraph logProbGraph = laplaceVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, mu, mu.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, laplaceVertex, DoubleTensor.create(0.25, 0.75)); LaplaceDistribution distribution = new LaplaceDistribution(0., 1.); double expectedDensity = distribution.logDensity(0.25) + distribution.logDensity(0.75); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }