### Question:
ChiSquaredVertex extends VertexImpl<DoubleTensor, DoubleVertex> implements DoubleVertex, Differentiable, ProbabilisticDouble, SamplableWithManyScalars<DoubleTensor>, LogProbGraphSupplier { @Override public LogProbGraph logProbGraph() { final DoublePlaceholderVertex xPlaceHolder = new DoublePlaceholderVertex(this.getShape()); final IntegerPlaceholderVertex kPlaceHolder = new IntegerPlaceholderVertex(k.getShape()); return LogProbGraph.builder() .input(this, xPlaceHolder) .input(k, kPlaceHolder) .logProbOutput(ChiSquared.logProbOutput(xPlaceHolder, kPlaceHolder)) .build(); } ChiSquaredVertex(@LoadShape long[] tensorShape,
                            @LoadVertexParam(K_NAME) Vertex<IntegerTensor, ?> k);  ChiSquaredVertex(long[] tensorShape, int k); @ExportVertexToPythonBindings  ChiSquaredVertex(IntegerVertex k);  ChiSquaredVertex(int k); @SaveVertexParam(K_NAME) IntegerVertex getK(); @Override DoubleTensor sampleWithShape(long[] shape, KeanuRandom random); @Override double logProb(DoubleTensor value); @Override LogProbGraph logProbGraph(); @Override Map<Vertex, DoubleTensor> dLogProb(DoubleTensor value, Set<? extends Vertex> withRespectTo);  }### Answer:
@Test public void logProbGraphMatchesKnownLogDensityOfScalar() { IntegerVertex k = ConstantVertex.of(1); ChiSquaredVertex vertex = new ChiSquaredVertex(k); LogProbGraph logProbGraph = vertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, k, k.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, vertex, DoubleTensor.scalar(0.5)); ChiSquaredDistribution chiSquaredDistribution = new ChiSquaredDistribution(1); double expectedLogDensity = chiSquaredDistribution.logDensity(0.5); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedLogDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { IntegerVertex k = ConstantVertex.of(1, 1); ChiSquaredVertex vertex = new ChiSquaredVertex(k); LogProbGraph logProbGraph = vertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, k, k.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, vertex, DoubleTensor.create(0.25, 0.75)); ChiSquaredDistribution chiSquaredDistribution = new ChiSquaredDistribution(1); double expectedLogDensity = chiSquaredDistribution.logDensity(0.25) + chiSquaredDistribution.logDensity(0.75); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedLogDensity); }