LinearNormalState#

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

Linear distrecte-time dynamical system with noise.

Parameters:
gGraph

Graph to be used for the dynamics

wEdgePropertyMap or float (optional, default: 1)

Coupling strength of each edge. If a scalar is given, it will be used for all edges.

sigmafloat (optional, default: .0)

Stochastic noise magnitude.

sVertexPropertyMap (optional, default: None)

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

Notes

This implements a distrecte time linear dynamical system with noise, i.e. each node has an variable $$s_i$$, which evolves in time according to a Markov chain with transitio probabilities:

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

References

Examples

>>> g = gt.collection.data["karate"].copy()
>>> s = g.new_vp("double", np.random.normal(0, 1, g.num_vertices()))
>>> w = g.new_ep("double", vals=np.random.normal(0, .1, g.num_edges()))
>>> state = gt.LinearNormalState(g, s=s, w=w)
>>> ss = []
>>> for t in range(10):
...     ret = state.iterate_sync()
...     ss.append(state.get_state().fa.copy())

>>> figure(figsize=(6, 4))
<...>
>>> for v in g.vertices():
...    plot(np.arange(len(ss)), [s[int(v)] for s in ss], "-o")
[...]
>>> xlabel(r"Time")
Text(...)
>>> ylabel(r"$s_i$")
Text(...)
>>> tight_layout()
>>> savefig("karate-linear-discrete.svg")


Methods

 Return a copy of the state. Returns list of "active" nodes, for states where this concept is used. 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. 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.

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

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.