Stochastic block models
In the previous chapters, we have already discussed stochastic models using the Monte Carlo simulation. So far, we have been discussing graphs and networks, so purely from that context, a community structure can also be viewed as a graph. In such graphs, nodes often cluster together as densely connected subgraphs. In general, the probability of an edge between two such nodes is a function of the cluster to which the node belongs.
A popular choice for such a network partition is the stochastic block model. A simple definition of a stochastic block model is characterized by a scalar n. This represents the number of groups or the number of clusters and a matrix that shows the nodes and their connections. For a more rigorous mathematical definition, you can refer to a statistics book.
Among a few Python packages that support stochastic models, PyMC is one that offers Markov Chain Monte Carlo (MCMC) and three building blocks for probability models, such as stochastic, deterministic...