### Question:
InverseGammaVertex 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(InverseGamma.logProbOutput(xPlaceholder, alphaPlaceholder, betaPlaceholder)) .build(); } InverseGammaVertex(@LoadShape long[] tensorShape,
                              @LoadVertexParam(ALPHA_NAME) Vertex<DoubleTensor, ?> alpha,
                              @LoadVertexParam(BETA_NAME) Vertex<DoubleTensor, ?> beta); @ExportVertexToPythonBindings  InverseGammaVertex(Vertex<DoubleTensor, ?> alpha, Vertex<DoubleTensor, ?> beta);  InverseGammaVertex(Vertex<DoubleTensor, ?> alpha, double beta);  InverseGammaVertex(double alpha, Vertex<DoubleTensor, ?> beta);  InverseGammaVertex(double alpha, double beta);  InverseGammaVertex(long[] tensorShape, Vertex<DoubleTensor, ?> alpha, double beta);  InverseGammaVertex(long[] tensorShape, double alpha, Vertex<DoubleTensor, ?> beta);  InverseGammaVertex(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(1.); InverseGammaVertex tensorInverseGammaVertex = new InverseGammaVertex(alpha, beta); LogProbGraph logProbGraph = tensorInverseGammaVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, alpha, alpha.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorInverseGammaVertex, DoubleTensor.scalar(0.5)); InverseGammaDist inverseGammaDist = new InverseGammaDist(2., 1.); double expectedDensity = Math.log(inverseGammaDist.density(0.5)); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }
@Test public void logProbGraphMatchesKnownLogDensityOfVector() { DoubleVertex alpha = ConstantVertex.of(2., 2.); DoubleVertex beta = ConstantVertex.of(1., 1.); InverseGammaVertex tensorInverseGammaVertex = new InverseGammaVertex(alpha, beta); LogProbGraph logProbGraph = tensorInverseGammaVertex.logProbGraph(); LogProbGraphValueFeeder.feedValue(logProbGraph, alpha, alpha.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, beta, beta.getValue()); LogProbGraphValueFeeder.feedValue(logProbGraph, tensorInverseGammaVertex, DoubleTensor.create(0.25, 0.75)); InverseGammaDist inverseGammaDist = new InverseGammaDist(2., 1.); double expectedDensity = Math.log(inverseGammaDist.density(0.25) * inverseGammaDist.density(0.75)); LogProbGraphContract.matchesKnownLogDensity(logProbGraph, expectedDensity); }