pyphi.estimate.SubstratePosterior#

class pyphi.estimate.SubstratePosterior(alpha_on, alpha_off, regime, prior, coverage, node_labels, provenance)[source]#

Bases: Serializable

Posterior distribution over substrates given observed transitions.

Each cell of the state-by-node TPM carries an independent Beta posterior: cell (s, i) is Beta(alpha_on[s, i], alpha_off[s, i]) over p(unit i is ON at t+1 | current state s). Rows follow the little-endian state order.

Draw concrete substrates with sample(); every existing PyPhi computation applies to the samples unchanged.

Variables:
Parameters:
property n_units: int#

Number of units in the substrate.

property n_states: int#

Total number of current states.

sample(*, seed=None, rng=None)[source]#

Draw one substrate from the posterior.

Every TPM cell is drawn independently from its Beta posterior; exactly one of seed or rng must be given.

Parameters:
  • seed (int | None) – Seed for a fresh, isolated np.random.default_rng.

  • rng (Generator | None) – An existing generator to draw from (advances its state).

Returns:

An ordinary Substrate.

Raises:

TypeError – If neither or both of seed and rng are given.

Return type:

Substrate

mean_substrate()[source]#

The posterior-mean substrate: every TPM cell at its Beta mean.

A reference point, not an estimator: φₛ of the mean substrate conflates epistemic uncertainty with the substrate’s own indeterminism (see the module docstring), so it must not be reported as an estimate of φₛ. Its role is to anchor reference computations such as the selection-margin screen in phi_posterior().

Return type:

Substrate

edge_probability(*, n_samples, seed, threshold)[source]#

Graded posterior probability of a causal edge between each unit pair.

Entry (a, b) is the fraction of posterior samples in which unit b’s estimated conditional varies by more than threshold along input axis a — that is, the maximum absolute difference in p(b = ON | current) between any two current states differing only in unit a exceeds threshold. This is the graded analogue of a connectivity matrix: an edge a -> b is present to the extent the data makes b depend on a.

The exact-equality oracle FactoredTPM.infer_cm() cannot serve here: on any continuously-estimated TPM every factor varies along every axis by sampling noise, so it saturates to fully connected. This method replaces that oracle for estimated substrates by asking how much a factor varies, at a caller-chosen scale.

threshold has no default: the scale below which a dependence is treated as absent is a modeling choice the caller must make.

Parameters:
  • n_samples (int) – Number of posterior draws to average over.

  • seed (int) – Seed for a fresh, isolated generator driving all draws (required; the statistic is otherwise irreproducible).

  • threshold (float) – Variation above which an input axis counts as an edge, on the p(ON) scale (in [0, 1]).

Returns:

An (n, n) array of edge-firing fractions in [0, 1].

Return type:

ndarray[tuple[Any, …], dtype[float64]]