NormalState#

class graph_tool.dynamics.NormalState(g, w=0, sigma=1, s=None)[source]#

Bases: DiscreteStateBase

Multivariate Normal distribution.

Parameters:
gGraph

Graph represening the conditional dependencies.

wEdgePropertyMap or float (optional, default: 0)

Inverse covariance (i.e. coupling strength) between nodes.

sigmaVertexPropertyMap or float (optional, default: 1)

Node standard deviation.

sVertexPropertyMap (optional, default: None)

Initial global state. If not provided, a random state will be chosen.

Notes

This implements a zero-mean multivariate Normal distribution.

If a node \(i\) is updated at time \(t\), the transition to state \(s_i(t+1)\) is given by

\[P(s_i(t+1)|\boldsymbol s(t), \boldsymbol A, \boldsymbol w, \boldsymbol \sigma) = \frac{\exp\left[-\frac{\left(s_i(t+1)+\sigma_i^2\sum_jA_{ij}w_{ij}s_j(t)\right)^2} {2\sigma_i^2}\right]} {\sqrt{2\pi}\sigma_i}\]

which will lead, asymptotically with \(t\to\infty\), to a zero-mean multivariate Normal distribution:

\[P(\boldsymbol s | \boldsymbol W) = \frac{\mathrm{e}^{-\frac{1}{2} {\boldsymbol x}^{\top}\boldsymbol W \boldsymbol x}} {\sqrt{(2\pi)^N |\boldsymbol W^{-1}|}},\]

where \(W_{ij}=w_{ij}\) for \(i\neq j\) and \(W_{ii}=1/\sigma_i^2\).

References

Examples

>>> g = gt.GraphView(gt.collection.data["polblogs"].copy(), directed=False)
>>> gt.remove_parallel_edges(g)
>>> g = gt.extract_largest_component(g, prune=True)
>>> state = gt.NormalState(g, sigma=0.001, w=-100)
>>> ret = state.iterate_sync(niter=1000)
>>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=state.s,
...               output="polblogs-normal.svg")
<...>
../_images/polblogs-normal.svg

Sample of a multivariate Normal on a political blog network.#

Methods

copy()

Return a copy of the state.

get_active()

Returns list of "active" nodes, for states where this concept is used.

get_state()

Returns the internal VertexPropertyMap with the current state.

iterate_async([niter])

Updates nodes asynchronously (i.e. single vertex chosen randomly), niter number of times.

iterate_sync([niter])

Updates nodes synchronously (i.e. a full "sweep" of all nodes in parallel), niter number of times.

reset_active()

Resets list of "active" nodes, for states where this concept is used.

set_active(active)

Sets the list of "active" nodes, for states where this concept is used.

copy()#

Return a copy of the state.

get_active()#

Returns list of “active” nodes, for states where this concept is used.

get_state()#

Returns the internal VertexPropertyMap with the current state.

iterate_async(niter=1)#

Updates nodes asynchronously (i.e. single vertex chosen randomly), niter number of times. This function returns the number of nodes that changed state.

iterate_sync(niter=1)#

Updates nodes synchronously (i.e. a full “sweep” of all nodes in parallel), niter number of times. This function returns the number of nodes that changed state.

If enabled during compilation, this algorithm runs in parallel (i.e. using more than one thread.)

reset_active()#

Resets list of “active” nodes, for states where this concept is used.

set_active(active)#

Sets the list of “active” nodes, for states where this concept is used.