pyphi.relations.RelationSample#

class pyphi.relations.RelationSample(relations, normalization, seed, num_self_relations, sum_phi_self_relations)[source]#

Bases: object

An i.i.d., coverage-weighted sample of non-self relations.

Relations are drawn with probability proportional to the size of their congruent overlap |O(S)| — the number of atoms covering them — which is known exactly per sample, so any sum over non-self relations is estimable without bias by Horvitz-Thompson reweighting (the union-of-sets sampling scheme of Karp & Luby (1983)). Self-relations are never sampled: there are at most |D| of them, and their exact totals are carried on the sample so the convenience estimators cover all relations.

Variables:
  • relations (tuple[Relation, ...]) – The sampled relations, drawn with replacement.

  • normalization (int) – The exact coverage-weighted total Σ_S |O(S)| over all non-self relations.

  • seed (int) – The seed of the isolated random generator that produced the sample.

  • num_self_relations (int) – The exact number of self-relations in the structure.

  • sum_phi_self_relations (float) – The exact Σφ_r over the self-relations.

estimate(f)[source]#

Return an unbiased estimate and standard error of Σ f(S) over all non-self relations.

Parameters:

f (Callable[[Relation], float]) – The per-relation summand.

Return type:

tuple[float, float]

num_relations()[source]#

Return an estimate and standard error of the total relation count, including the exact self-relation count.

Return type:

tuple[float, float]

sum_phi()[source]#

Return an estimate and standard error of Σφ_r over all relations, including the exact self-relation total.

Return type:

tuple[float, float]