pymc.vectorize_over_posterior#

pymc.vectorize_over_posterior(outputs, posterior, input_rvs, allow_rvs_in_graph=True, sample_dims=('chain', 'draw'))[source]#

Vectorize outputs over posterior samples of subset of input rvs.

This function creates a new graph for the supplied outputs, where the required subset of input rvs are replaced by their posterior samples (chain and draw dimensions are flattened). The other input tensors are kept as is.

Parameters:
outputslist[Variable]

The list of variables to vectorize over the posterior samples.

posteriorxr.Dataset

The posterior samples to use as replacements for the input_rvs.

input_rvslist[Variable]

The list of random variables to replace with their posterior samples.

allow_rvs_in_graphbool

Whether to allow random variables to be present in the graph. If False, an error will be raised if any random variables are found in the graph. If True, the remaining random variables will be resized to match the number of draws from the posterior.

sample_dimstuple[str, …]

The dimensions of the posterior samples to use for vectorizing the input_rvs.

Returns:
vectorized_outputslist[Variable]

The vectorized variables

Raises:
RuntimeError

If random variables are found in the graph and allow_rvs_in_graph is False