DataPrior

phasic.svgd.DataPrior(
    graph,
    observed_data,
    sd=2.0,
    fixed=None,
    nr_moments=None,
    rewards=None,
    theta_dim=None,
    theta_init=None,
    discrete=None,
    verbose=False,
)

Data-informed prior estimated from observed data.

Auto-detects the graph type and uses method-of-moments (standard graphs) or probability matching (joint probability graphs) to estimate parameter prior means from the data. The result is a list of per-parameter GaussPrior objects (or None for fixed parameters) that can be passed directly to :meth:Graph.svgd.

Implements the list-like interface so SVGD can iterate over per-parameter priors, and the Prior interface (__call__, sample, plot) for use as a single prior object.

Parameters

graph : Graph

Parameterized graph (standard or joint probability).

observed_data : np.ndarray

Observed data appropriate for the graph type.

sd : float = 2.0

Multiplier applied to the asymptotic standard error to obtain the prior standard deviation (passed as std_multiplier).

fixed : list = None

List of (index, value) tuples pinning specific parameters.

nr_moments : int = None

Number of moments (standard graphs only).

rewards : np.ndarray = None

Reward vectors (standard graphs only).

theta_dim : int = None

Number of model parameters. Inferred from the graph when None.

theta_init : np.ndarray = None

Initial guess for the free parameters.

discrete : bool = None

True for discrete models, False for continuous (standard graphs only).

verbose : bool = False

Print progress information.

Examples

>>> from phasic import Graph, DataPrior
>>> g = Graph(...)
>>> data = g.sample(1000)
>>> svgd = g.svgd(data, prior=DataPrior(g, data))

Attributes

Name Description
method Name of the estimation method used.
result The underlying MoMResult or ProbMatchResult.
std Standard errors of the parameter estimates.
success Whether the underlying optimisation converged.
theta Parameter estimate from the underlying method.

Methods

Name Description
plot Plot per-parameter prior distributions.
sample Sample from per-parameter priors and concatenate.

plot

phasic.svgd.DataPrior.plot(axes=None, figsize=None, return_axes=False)

Plot per-parameter prior distributions.

Parameters

axes : array of Axes = None

Pre-existing axes (one per non-fixed parameter).

figsize : tuple = None

Figure size when creating new axes.

return_axes : bool = False

If True, return the axes array instead of calling plt.show().

Returns

: array of Axes or None

sample

phasic.svgd.DataPrior.sample(key, shape)

Sample from per-parameter priors and concatenate.

Parameters

key : jax.random.PRNGKey

Random key.

shape : tuple

(n_particles, theta_dim)

Returns

: jnp.ndarray

Samples with shape (n_particles, theta_dim).