### Question:
BinomialVertex extends VertexImpl<IntegerTensor, IntegerVertex> implements IntegerVertex, ProbabilisticInteger, SamplableWithManyScalars<IntegerTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { IntegerPlaceholderVertex kPlaceholder = new IntegerPlaceholderVertex(this.getShape()); DoublePlaceholderVertex pPlaceholder = new DoublePlaceholderVertex(p.getShape()); IntegerPlaceholderVertex nPlaceholder = new IntegerPlaceholderVertex(n.getShape()); return LogProbGraph.builder() .input(this, kPlaceholder) .input(p, pPlaceholder) .input(n, nPlaceholder) .logProbOutput(Binomial.logProbOutput(kPlaceholder, pPlaceholder, nPlaceholder)) .build(); } BinomialVertex(@LoadShape long[] tensorShape,
                          @LoadVertexParam(P_NAME) Vertex<DoubleTensor, ?> p,
                          @LoadVertexParam(N_NAME) Vertex<IntegerTensor, ?> n);  BinomialVertex(long[] tensorShape, double p, Vertex<IntegerTensor, ?> n);  BinomialVertex(long[] tensorShape, Vertex<DoubleTensor, ?> p, int n);  BinomialVertex(long[] tensorShape, double p, int n); @ExportVertexToPythonBindings  BinomialVertex(Vertex<DoubleTensor, ?> p, Vertex<IntegerTensor, ?> n);  BinomialVertex(double p, Vertex<IntegerTensor, ?> n);  BinomialVertex(Vertex<DoubleTensor, ?> p, int n);  BinomialVertex(double p, int n); @Override double logProb(IntegerTensor k); @Override LogProbGraph logProbGraph(); @Override Map<Vertex, DoubleTensor> dLogProb(IntegerTensor value, Set<? extends Vertex> withRespectTo); @Override IntegerTensor sampleWithShape(long[] shape, KeanuRandom random); @SaveVertexParam(P_NAME) DoubleVertex getP(); @SaveVertexParam(N_NAME) IntegerVertex getN();  }### Answer:
@Test public void logProbGraphIsCorrectForKnownScalarValues() { DoubleVertex p = ConstantVertex.of(0.25); IntegerVertex n = ConstantVertex.of(5); BinomialVertex binomialVertex = new BinomialVertex(p, n); LogProbGraph logProbGraph = binomialVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, p, p.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, n, n.getValue()); BinomialDistribution distribution = new BinomialDistribution(5, 0.25); for (int i = 0; i < 5; i++) { LogProbGraphValueFeeder.feedValueAndCascade(logProbGraph, binomialVertex, IntegerTensor.scalar(i)); double expectedDensity = distribution.logProbability(i); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); } }
@Test public void logProbGraphIsCorrectForKnownVectorValues() { DoubleVertex p = ConstantVertex.of(0.25); IntegerVertex n = ConstantVertex.of(100); int k1 = 20; int k2 = 80; BinomialVertex testBinomialVertex = new BinomialVertex(new long[]{2}, p, n); LogProbGraph logProbGraph = testBinomialVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, p, p.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, n, n.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, testBinomialVertex, IntegerTensor.create(k1, k2)); BinomialDistribution distribution = new BinomialDistribution(100, 0.25); double expectedDensity = distribution.logProbability(k1) + distribution.logProbability(k2); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }