graph_tool.inference.MCMCState#
- class graph_tool.inference.MCMCState[source]#
Bases:
ABCBase state that implements single-flip MCMC sweeps
Methods
mcmc_sweep([beta, c, d, niter, ...])Perform
nitersweeps of a Metropolis-Hastings acceptance-rejection MCMC to sample network partitions.- mcmc_sweep(beta=1.0, c=0.5, d=0.01, niter=1, entropy_args={}, allow_vacate=True, sequential=True, deterministic=False, vertices=None, verbose=False, **kwargs)[source]#
Perform
nitersweeps of a Metropolis-Hastings acceptance-rejection MCMC to sample network partitions.- Parameters:
- beta
float(optional, default:1.) Inverse temperature.
- c
float(optional, default:.5) Sampling parameter
cfor move proposals: For \(c\to 0\) the blocks are sampled according to the local neighborhood of a given node and their block connections; for \(c\to\infty\) the blocks are sampled randomly. Note that only for \(c > 0\) the MCMC is guaranteed to be ergodic.- d
float(optional, default:.01) Probability of selecting a new (i.e. empty) group for a given move.
- niter
int(optional, default:1) Number of sweeps to perform. During each sweep, a move attempt is made for each node.
- entropy_args
dict(optional, default:{}) Entropy arguments, with the same meaning and defaults as in
graph_tool.inference.BlockState.entropy().- allow_vacate
bool(optional, default:True) Allow groups to be vacated.
- sequential
bool(optional, default:True) If
sequential == Trueeach vertex move attempt is made sequentially, where vertices are visited in random order. Otherwise the moves are attempted by sampling vertices randomly, so that the same vertex can be moved more than once, before other vertices had the chance to move.- deterministic
bool(optional, default:False) If
sequential == Trueanddeterministic == Truethe vertices will be visited in deterministic order.- vertices
listof ints (optional, default:None) If provided, this should be a list of vertices which will be moved. Otherwise, all vertices will.
- verbose
bool(optional, default:False) If
verbose == True, detailed information will be displayed.
- beta
- Returns:
- dS
float Entropy difference after the sweeps.
- nattempts
int Number of vertex moves attempted.
- nmoves
int Number of vertices moved.
- dS
Notes
This algorithm has an \(O(E)\) complexity, where \(E\) is the number of edges (independent of the number of groups).
References
[peixoto-efficient-2014]Tiago P. Peixoto, “Efficient Monte Carlo and greedy heuristic for the inference of stochastic block models”, Phys. Rev. E 89, 012804 (2014), DOI: 10.1103/PhysRevE.89.012804 [sci-hub, @tor], arXiv: 1310.4378