pyphi.relations.Relations#
- class pyphi.relations.Relations(*args, **kwargs)[source]#
Bases:
Displayable,ToPandasMixin,SerializableA set of relations among distinctions.
- phi_mean_std()[source]#
Return the population mean and standard deviation of φ_r.
Derived from the count, Σφ_r, and Σφ_r², so it is exact on any backend that answers those queries without enumeration.
- Raises:
ValueError – If there are no relations.
- Return type:
- num_relations_of_degree(degree)[source]#
Return the number of relations with exactly
degreerelata.Degree 1 counts the self-relations.
- degree_spectrum()[source]#
Return
{degree: (count, Σφ_r)}over all relations.Degrees with no relations are omitted. The counts sum to
num_relations()and the φ sums tosum_phi().
- sum_phi_by_distinction(distinctions)[source]#
Return each distinction’s incident Σφ_r, aligned to
distinctions.A distinction’s incident Σφ_r is the sum of φ_r over every relation that contains it, including its self-relation. The result is a tuple parallel to
distinctions; a distinction that no relation reaches contributes0.0.
- phi_histogram()[source]#
Return
{φ_r: count}over all relations.Keys are grouped at the configured precision (
pyphi.numerics.round_to_precision()), so mathematically equal values that differ by float noise share a bucket. Counts sum tonum_relations().
- binding_matrix()[source]#
Return the atom-pair binding matrix of the relational structure.
Entry
(a, b)is the total minimum density (φ_r / |O|) of the non-self relations whose congruent overlap contains both atoms — the strength with which the two unit-states are jointly bound by relations. The diagonal decomposes the apportioned relation strength per atom. Index and columns are the atoms (state-tagged units) incident to at least one non-self relation, sorted. Self-relations are excluded: the matrix measures binding between distinctions.- Return type:
DataFrame
- strongest(k=None, min_phi=None, max_degree=None)[source]#
Yield relations in descending φ_r order.
Ties in φ_r yield in an unspecified but deterministic order.
- Parameters:
- Return type:
- materialize(max_degree=None, min_phi=None)[source]#
Return the relations as an explicit
ConcreteRelations.Enumerates relation objects from a backend that otherwise answers queries in closed form.
max_degreeandmin_phi(tolerant≥) bound what is materialized.- Parameters:
- Return type:
- maximal_relations()[source]#
Return the relations maximal under set inclusion of their relata.
The facets of the relation complex: every relation’s relata are a subset of some maximal relation’s. Degree ≥ 2 only; self-relations are excluded. Computed in closed form from the distinctions — on a filtered set (e.g. from
materialize()with bounds) the result is the facets of the complex generated by the participating distinctions, not of the filtered subset. For φ_r-ranked relations seestrongest().- Return type:
- maximal_faces()[source]#
Return the relation faces maximal under set inclusion of their relata (causes/effects), across all relations; see
maximal_faces().- Return type:
- maximal_relations_by_distinction(distinctions)[source]#
Return, for each distinction, the maximal relations containing it.
Parallel to
distinctions; a distinction contained in no maximal relation (an isolated distinction) gets an empty tuple. Within each tuple, facets are ordered by their sorted mechanism tuples.- Return type:
- sample(n, *, seed)[source]#
Draw a coverage-weighted sample of relations.
Implemented on backends that hold the distinction set; see
AnalyticalRelations.sample().- Parameters:
- Return type: