networksns.statistical_models.darn_simulation

networksns.statistical_models.darn_simulation(p, Q, Y, n, s, z_p='uniform', param='local')

Simulate a temporal network following the \(DARN(p)\) model.

For a temporal network described by a time series of adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\) the \(DARN(p)\) model [1] describes the state \(A^{t}_{ij}\) of the link \((i,j)\) at time \(t\) with the following copying mechanism: (i) with probability \(q_{ij}\), the link is copied from the past itself, (ii) then the lag is selected with probability \(z_i\) with \(i=1,\ldots,p\), where \(p\) represents the order of the memory, (iii) while with probability \(1-q_{ij}\), it is sampled with (marginal) probability \(y_{ij}\).

In other words, the state \(A_{ij}^t\) of the link \((i,j)\) is described by the following stochastic process at discrete time

\(\phantom{aaaaaaaaaaaaaaaaaaa}A^{t}_{ij}= Q^{t}_{ij} A^{t-Z_p^{t}}_{ij} + (1-Q^{t}_{ij}) Y^{t}_{ij}\)

with \(Q_{ij}^t\sim B(q_{ij})\) Bernoulli variable, \(Z_p^t\) random variable picking values from \(1\) to \(p\) with probability \(z_i\) \(i=1,\ldots,p\), respectively, and \(Y_{ij}^t\sim B(y_{ij})\) Bernoulli variable.

Parameters:
  • p (integer) – Markov order

  • Q (array_like) – Symmetric matrix. It represents the link-specific probability of copying from the past. A float input is accepted in the case of homogeneous copying probabilities for each link.

  • Y (array_like) –

  • matrix. (Symmetric) –

  • probabilities. (Bernoulli marginal) – A float input is accepted in the case of homogeneous marginal probabilities for each link.

  • n (integer) – number of nodes in the graph.

  • s (integer) – Temporal Network sample size, i.e. the length of the time series of adjacency matrices.

  • z_p (array/string, optional) –

    stochastic array of length \(p\) representing the memory distribution \(Z_p\). Default: 'uniform'. Possible strings:

    • 'uniform': \(Z_p = (\frac{1}{p}, \dots, \frac{1}{p}\)),

    • 'exponential': \(Z_p = \frac{(1, e^{-1}, \dots, e^{-p+1})}{\left|\left|(1, e^{-1}, \dots, e^{-p+1}\right|\right|_2)}\)

    • 'normal': let \(f(x)=\frac{e^{-(x-1)^2/2}}{\sqrt{2\pi}}\) then \(Z_p = \frac{(f(0), \dots, f(p-1))}{\left|\left|(f(0), \dots, f(p-1))\right|\right|}\)

  • param – If 'local' the value of the parameters depends on the couple \((i,j)\), i.e. parameters are link-specific, if 'global' it does not depend on the \((i,j)\). Default: 'local'.

Returns:

simulation: (list) Temporal network produced by a \(DARN(p)\) model.

Examples

>>>  from networksns import statistical_models as sm
>>>  import numpy as np

Define input parameters

>>>    n = 50
>>>    s = 100
>>>    p = 3
>>>    Q = (np.ones((n, n)) - np.diag(np.ones(n))) * 0.5
>>>    Y = (np.ones((n, n)) - np.diag(np.ones(n)))  * 0.3

Simulate the temporal network

>>>   time_series = sm.darn_simulation(p, Q, Y, n, s)

References