MultiflipMCMCState#
- class graph_tool.inference.MultiflipMCMCState(entropy_args={})[source]#
Bases:
EntropyStateBase state that implements multiflip (merge-split) MCMC sweeps.
Methods
Return the current default values for the parameters of the function
entropy(), together with other operations that depend on them.multiflip_mcmc_sweep([beta, c, psingle, ...])Perform
nitersweeps of a Metropolis-Hastings acceptance-rejection MCMC with multiple simultaneous moves (i.e. merges and splits) to sample network partitions.Reset the current default values for the parameters of the function
entropy(), together with other operations that depend on them.update_entropy_args(**kwargs)Update the default values for the parameters of the function
entropy()from the keyword arguments, in a stateful way, together with other operations that depend on them.- get_entropy_args()#
Return the current default values for the parameters of the function
entropy(), together with other operations that depend on them.
- multiflip_mcmc_sweep(beta=1.0, c=0.5, psingle=None, psplit=1, pmerge=1, pmergesplit=1, pmovelabel=0, d=0.01, gibbs_sweeps=10, niter=1, entropy_args={}, accept_stats=None, verbose=False, **kwargs)[source]#
Perform
nitersweeps of a Metropolis-Hastings acceptance-rejection MCMC with multiple simultaneous moves (i.e. merges and splits) 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.- psingle
float(optional, default:None) Relative probability of proposing a single node move. If
None, it will be selected as the number of nodes in the graph.- psplit
float(optional, default:1) Relative probability of proposing a group split.
- pmerge
float(optional, default:1) Relative probability of proposing a group merge.
- pmergesplit
float(optional, default:1) Relative probability of proposing a marge-split move.
- pmovelabel
float(optional, default:0) Relative probability of proposing a group label move.
- d
float(optional, default:1) Probability of selecting a new (i.e. empty) group for a given single-node move.
- gibbs_sweeps
int(optional, default:10) Number of sweeps of Gibbs sampling to be performed (i.e. each node is attempted once per sweep) to refine a split proposal.
- niter
int(optional, default:1) Number of sweeps to perform. During each sweep, a move attempt is made for each node, on average.
- entropy_args
dict(optional, default:{}) Entropy arguments, with the same meaning and defaults as in
graph_tool.inference.BlockState.entropy().- accept_stats
dict(optional, default:None) If provided, this dictionary will be updated with the proposal and acceptance counts for each kind of move.
- 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-merge-split-2020]Tiago P. Peixoto, “Merge-split Markov chain Monte Carlo for community detection”, Phys. Rev. E 102, 012305 (2020), DOI: 10.1103/PhysRevE.102.012305 [sci-hub, @tor], arXiv: 2003.07070