Prior#

class pymc_marketing.prior.Prior(distribution, *, dims=None, centered=True, transform=None, **parameters)[source]#

A class to represent a prior distribution.

This is the alternative to using the dictionaries in PyMC-Marketing models but provides added flexibility and functionality.

Make use of the various helper methods to understand the distributions better.

  • preliz attribute to get the equivalent distribution in preliz

  • sample_prior method to sample from the prior

  • graph get a dummy model graph with the distribution

  • constrain to shift the distribution to a different range

Parameters:
distributionstr

The name of PyMC distribution.

dimsDims, optional

The dimensions of the variable, by default None

centeredbool, optional

Whether the variable is centered or not, by default True. Only allowed for Normal distribution.

transformstr, optional

The name of the transform to apply to the variable after it is created, by default None or no transform. The transformation must be registered with register_tensor_transform function or be available in either pytensor.tensor or pymc.math.

Methods

Prior.__init__(distribution, *[, dims, ...])

Prior.constrain(lower, upper[, mass, kwargs])

Create a new prior with a given mass constrained within the given bounds.

Prior.create_likelihood_variable(name, mu, ...)

Create a likelihood variable from the prior.

Prior.create_variable(name)

Create a PyMC variable from the prior.

Prior.deepcopy()

Return a deep copy of the prior.

Prior.from_dict(data)

Create a Prior from the dictionary format.

Prior.sample_prior([coords, name])

Sample the prior distribution for the variable.

Prior.to_dict()

Convert the prior to dictionary format.

Prior.to_graph()

Generate a graph of the variables.

Attributes

dims

The dimensions of the variable.

distribution

The name of the PyMC distribution.

non_centered_distributions

preliz

Create an equivalent preliz distribution.

transform

The name of the transform to apply to the variable after it is created.

pymc_distribution

pytensor_transform