### Question:
GaussianVertex 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 sigmaPlaceholder = new DoublePlaceholderVertex(sigma.getShape()); return LogProbGraph.builder() .input(this, xPlaceholder) .input(mu, muPlaceholder) .input(sigma, sigmaPlaceholder) .logProbOutput(Gaussian.logProbOutput(xPlaceholder, muPlaceholder, sigmaPlaceholder).sum()) .build(); } GaussianVertex(@LoadShape long[] shape,
                          @LoadVertexParam(MU_NAME) Vertex<DoubleTensor, ?> mu,
                          @LoadVertexParam(SIGMA_NAME) Vertex<DoubleTensor, ?> sigma); @ExportVertexToPythonBindings  GaussianVertex(Vertex<DoubleTensor, ?> mu, Vertex<DoubleTensor, ?> sigma);  GaussianVertex(Vertex<DoubleTensor, ?> mu, double sigma);  GaussianVertex(double mu, Vertex<DoubleTensor, ?> sigma);  GaussianVertex(double mu, double sigma);  GaussianVertex(long[] tensorShape, Vertex<DoubleTensor, ?> mu, double sigma);  GaussianVertex(long[] tensorShape, double mu, Vertex<DoubleTensor, ?> sigma);  GaussianVertex(long[] tensorShape, double mu, double sigma);  GaussianVertex(long[] tensorShape, DoubleTensor mu, DoubleTensor sigma);  GaussianVertex(DoubleTensor mu, DoubleTensor sigma); @SaveVertexParam(MU_NAME) DoubleVertex getMu(); @SaveVertexParam(SIGMA_NAME) DoubleVertex getSigma(); @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.); DoubleVertex sigma = ConstantVertex.of(1.); GaussianVertex vertex = new GaussianVertex(mu, sigma); LogProbGraph logProbGraph = vertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, mu, mu.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, sigma, sigma.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, vertex, DoubleTensor.scalar(0.5)); NormalDistribution distribution = new NormalDistribution(0., 1.); double expectedLogDensity = distribution.logDensity(0.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedLogDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex mu = ConstantVertex.of(0., 0.); DoubleVertex sigma = ConstantVertex.of(1., 1.); GaussianVertex vertex = new GaussianVertex(mu, sigma); LogProbGraph logProbGraph = vertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, mu, mu.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, sigma, sigma.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, vertex, DoubleTensor.create(0.25, -0.75)); NormalDistribution distribution = new NormalDistribution(0., 1.); double expectedLogDensity = distribution.logDensity(0.25) + distribution.logDensity(-0.75); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedLogDensity); }