distributions.chain¶
Module: distributions.chain
¶
Inheritance diagram for selectinf.distributions.chain
:
A simple implementation of Besag and Clifford’s generalized Monte Carlo Significance Tests.
Classes¶
markov_chain
¶
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.
-
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.