@Override public T sample(KeanuRandom random) { return parent.sample(random); }
@Override public BooleanTensor sample(KeanuRandom random) { return predicate.sample(); }
@Override public DoubleTensor sample(KeanuRandom random) { return op.apply(inputVertex.sample(random)); }
@Override public DoubleTensor sample(KeanuRandom random) { for (Vertex<? extends Tensor> input : inputs.values()) { input.sample(); } return calculate(); }
@Override public Tensor<T> sample(KeanuRandom random) { return op(inputVertex.sample(random)); }
@Override public BooleanTensor sample(KeanuRandom random) { return op(a.sample(random)); }
@Override public OUT sample(KeanuRandom random) { return op(inputVertex.sample(random)); }
@Override public T sample(KeanuRandom random) { Vertex<T> selector = getSelector(); return selector.sample(random); }
@Override public DoubleTensor sample(KeanuRandom random) { return inputVertex.sample(random).toDouble(); }
@Override public Tensor<T> sample(KeanuRandom random) { return op(inputVertex.sample(random)); }
@Override public DoubleTensor sample(KeanuRandom random) { return applyReduce(vertex -> vertex.sample(random)); }
@Override public IntegerTensor sample(KeanuRandom random) { return inputVertex.sample(random).toInteger(); }
private <T> void setFor(Variable<T, ?> variable, KeanuRandom random, Proposal proposal) { Vertex<T> vertex = vertexLookup.get(variable.getReference()); proposal.setProposal(variable, vertex.sample(random)); }
@Override public IntegerTensor sample(KeanuRandom random) { final CPTCondition condition = CPTCondition.from(inputs, (vertex) -> vertex.sample(random).scalar()); IntegerVertex vertex = conditions.get(condition); return vertex == null ? defaultResult.sample(random) : vertex.sample(random); }
@Override public DoubleTensor sample(KeanuRandom random) { final CPTCondition condition = CPTCondition.from(inputs, (vertex) -> vertex.sample(random).scalar()); DoubleVertex vertex = conditions.get(condition); return vertex == null ? defaultResult.sample(random) : vertex.sample(random); }
private static <T> void updateVertexValue(Vertex<T> vertex) { if (vertex.isProbabilistic()) { if (!vertex.hasValue()) { vertex.setValue(vertex.sample()); } } else { if (!vertex.isObserved()) { vertex.setValue(((NonProbabilistic<T>) vertex).calculate()); } } } }