Reference / binference.priors.PolyaTree

binference.priors.PolyaTree

class binference.priors.PolyaTree(c=1.0, power=2.0, base='flat')[source]

Finite Polya-tree prior on an ordered 1-D grid (a balanced binary Dirichlet-tree).

Bins are split recursively into halves; a split at level \(m\) (root = 1) has Beta concentrations \(c\,m^{p}\cdot 2 G_0(\text{child})/G_0(\text{parent})\), so the prior mean is the base measure \(G_0\) and fluctuations shrink at finer scales (power=2 gives absolutely continuous limits; Lavine 1992). A conjugate, multi-scale alternative to smoothness priors.

Parameters:
cfloat

Overall concentration (larger = closer to the base measure).

powerfloat

Growth of concentration with depth.

baseDensity, “flat”, callable or array_like (K,)

Base measure, read by Density.coerce (an array is masses per bin). The default is flat in the measure coordinate.

__init__(c=1.0, power=2.0, base='flat')[source]

Methods

__init__([c, power, base])

bind(bins)

describe(bins[, counts])

The tree on bins, drawn as text.

Attributes

kind

"fractions" (a distribution on the simplex) or "rates"

describe(bins, counts=None)

The tree on bins, drawn as text.

Each line is a branch: its concentration α, the share of its parent it takes on average, the mean fraction of the population below it, and the bins it leads to. With counts the drawing shows the posterior given them, each branch’s concentration raised by the counts of the bins below it.

Parameters:
binsBins

The bins it is drawn on.

countsarray_like (K,), optional

Counts per bin.

Examples

>>> import binference
>>> bins = binference.Bins.linear(0.0, 1.0, 4)
>>> print(binference.priors.PolyaTree().describe(bins))
PolyaTree: prior, on 4 bins
root: bins 0–3
├── α=1  share 0.50  mass 0.500  bins 0–1
│   ├── α=4  share 0.50  mass 0.250  bin 0 [0, 0.25)
│   └── α=4  share 0.50  mass 0.250  bin 1 [0.25, 0.5)
└── α=1  share 0.50  mass 0.500  bins 2–3
    ├── α=4  share 0.50  mass 0.250  bin 2 [0.5, 0.75)
    └── α=4  share 0.50  mass 0.250  bin 3 [0.75, 1)