distributions.chain

Module: distributions.chain

Inheritance diagram for selectinf.distributions.chain:

digraph inheritance1f333bfbce { rankdir=LR; size="8.0, 12.0"; "distributions.chain.markov_chain" [URL="#selectinf.distributions.chain.markov_chain",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Abstract implementation of a Markov chain."]; "distributions.chain.reversible_markov_chain" [URL="#selectinf.distributions.chain.reversible_markov_chain",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="An abstract representation of a Markov chain that"]; "distributions.chain.markov_chain" -> "distributions.chain.reversible_markov_chain" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A simple implementation of Besag and Clifford’s generalized Monte Carlo Significance Tests.

Classes

markov_chain

class selectinf.distributions.chain.markov_chain[source]

Bases: object

Abstract implementation of a Markov chain.

__init__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

forward_step()[source]
backward_step()[source]
get_state()[source]
set_state(state)[source]
property state
next()[source]

reversible_markov_chain

class selectinf.distributions.chain.reversible_markov_chain[source]

Bases: selectinf.distributions.chain.markov_chain

An abstract representation of a Markov chain that is reversible with respect to some stationary distribution.

__init__($self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

step()[source]
forward_step()[source]

For a reversible chain, a forward_step is just a step.

backward_step()[source]

For a reversible chain, a backward_step is just a step.

get_state()
next()
set_state(state)
property state

Functions

selectinf.distributions.chain.parallel_test(reversible_chain, null_state, test_statistic, ndraw=20)[source]

Besag and Clifford’s parallel test for reversible Markov chains.

Parameters

reversible_chain : iterable

An object implementing a Markov chain, with forward_step and backward_step methods.

null_state : object

An object nominally drawn from the stationary distribution.

test_statistic : callable

A test statistic to compute on each state of the chain. The overall test statistic is the ranking of test_statistic(null_state) in a sample of ndraw steps of the chain.

ndraw : int

How many total draws of the chain should be made? Includes null_state as one of these draws.

Returns

rank : int

How many of the draws had a test statistic less than the observed value? Ties are handled by randomization.

Notes

The attribute chain.state is reset to its initial value after running.

selectinf.distributions.chain.serial_test(reversible_chain, null_state, test_statistic, ndraw=20)[source]

Besag and Clifford’s parallel test for reversible Markov chains.

Parameters

reversible_chain : iterable

An object implementing a Markov chain, with next method returning current state.

null_state : object

An object nominally drawn from the stationary distribution.

test_statistic : callable

A test statistic to compute on each state of the chain. The overall test statistic is the ranking of test_statistic(null_state) in a sample of ndraw steps of the chain.

ndraw : int

How many total draws of the chain should be made? Includes null_state as one of these draws. Ties are handled by randomization.

Returns

rank : int

How many of the draws had a test statistic less than the observed value?

Notes

The attribute chain.state is reset to its initial value after running.