### Question:
GammaVertex extends VertexImpl<DoubleTensor, DoubleVertex> implements DoubleVertex, Differentiable, ProbabilisticDouble, SamplableWithManyScalars<DoubleTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { final DoublePlaceholderVertex xPlaceholder = new DoublePlaceholderVertex(this.getShape()); final DoublePlaceholderVertex thetaPlaceholder = new DoublePlaceholderVertex(theta.getShape()); final DoublePlaceholderVertex kPlaceholder = new DoublePlaceholderVertex(k.getShape()); return LogProbGraph.builder() .input(this, xPlaceholder) .input(theta, thetaPlaceholder) .input(k, kPlaceholder) .logProbOutput(Gamma.logProbOutput(xPlaceholder, thetaPlaceholder, kPlaceholder)) .build(); } GammaVertex(@LoadShape long[] tensorShape,
                       @LoadVertexParam(THETA_NAME) Vertex<DoubleTensor, ?> theta,
                       @LoadVertexParam(K_NAME) Vertex<DoubleTensor, ?> k); @ExportVertexToPythonBindings  GammaVertex(Vertex<DoubleTensor, ?> theta,
                       Vertex<DoubleTensor, ?> k);  GammaVertex(Vertex<DoubleTensor, ?> theta, double k);  GammaVertex(double theta, Vertex<DoubleTensor, ?> k);  GammaVertex(double theta, double k); @SaveVertexParam(THETA_NAME) DoubleVertex getTheta(); @SaveVertexParam(K_NAME) DoubleVertex getK(); @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 theta = ConstantVertex.of(1.5); DoubleVertex k = ConstantVertex.of(1.); GammaVertex tensorGamma = new GammaVertex(theta, k); LogProbGraph logProbGraph = tensorGamma.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, theta, theta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, k, k.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorGamma, DoubleTensor.scalar(0.5)); GammaDistribution distribution = new GammaDistribution(1., 1.5); double expectedDensity = distribution.logDensity(0.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex theta = ConstantVertex.of(1.0, 1.0); DoubleVertex k = ConstantVertex.of(5., 5.); GammaVertex tensorGamma = new GammaVertex(theta, k); LogProbGraph logProbGraph = tensorGamma.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, theta, theta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, k, k.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorGamma, DoubleTensor.create(1., 3.)); GammaDistribution distribution = new GammaDistribution(5., 1.); double expectedDensity = distribution.logDensity(1.) + distribution.logDensity(3.); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }