### Question:
BetaVertex extends VertexImpl<DoubleTensor, DoubleVertex> implements DoubleVertex, Differentiable, ProbabilisticDouble, SamplableWithManyScalars<DoubleTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { final DoublePlaceholderVertex xPlaceHolder = new DoublePlaceholderVertex(this.getShape()); final DoublePlaceholderVertex alphaPlaceHolder = new DoublePlaceholderVertex(alpha.getShape()); final DoublePlaceholderVertex betaPlaceHolder = new DoublePlaceholderVertex(beta.getShape()); return LogProbGraph.builder() .input(this, xPlaceHolder) .input(alpha, alphaPlaceHolder) .input(beta, betaPlaceHolder) .logProbOutput(Beta.logProbOutput(xPlaceHolder, alphaPlaceHolder, betaPlaceHolder)) .build(); } BetaVertex(@LoadShape long[] tensorShape,
                      @LoadVertexParam(ALPHA_NAME) Vertex<DoubleTensor, ?> alpha,
                      @LoadVertexParam(BETA_NAME) Vertex<DoubleTensor, ?> beta); @ExportVertexToPythonBindings  BetaVertex(Vertex<DoubleTensor, ?> alpha, Vertex<DoubleTensor, ?> beta);  BetaVertex(DoubleVertex alpha, double beta);  BetaVertex(double alpha, DoubleVertex beta);  BetaVertex(double alpha, double beta);  BetaVertex(long[] tensorShape, DoubleVertex alpha, double beta);  BetaVertex(long[] tensorShape, double alpha, DoubleVertex beta);  BetaVertex(long[] tensorShape, double alpha, double beta); @SaveVertexParam(ALPHA_NAME) DoubleVertex getAlpha(); @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 alpha = ConstantVertex.of(2.); DoubleVertex beta = ConstantVertex.of(3.); BetaVertex tensorBetaVertex = new BetaVertex(alpha, beta); LogProbGraph logProbGraph = tensorBetaVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, alpha, alpha.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorBetaVertex, DoubleTensor.scalar(0.5)); BetaDistribution betaDistribution = new BetaDistribution(2., 3.); double expectedDensity = betaDistribution.logDensity(0.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex alpha = ConstantVertex.of(2., 2.); DoubleVertex beta = ConstantVertex.of(3., 3.); BetaVertex tensorBetaVertex = new BetaVertex(alpha, beta); LogProbGraph logProbGraph = tensorBetaVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, alpha, alpha.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorBetaVertex, DoubleTensor.create(0.25, 0.1)); BetaDistribution betaDistribution = new BetaDistribution(2., 3.); double expectedDensity = betaDistribution.logDensity(0.25) + betaDistribution.logDensity(0.1); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }