networksns.statistical_models.tgrg_directed_simulation

networksns.statistical_models.tgrg_directed_simulation(n, T, theta_0_in=None, theta_0_out=None, phi_0_in=None, phi_0_out=None, phi_1_in=None, phi_1_out=None, sigma_in=None, sigma_out=None)

Simulate a directed temporal network following the Temporally Generalized Random Graph model (\(TGRG\)).

In the \(TGRG\) model for directed graphs [1], with temporal network described by a time series of adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\) with \(A_{ij}^t\neq A_{ji}^t\) in general,

each node \(i\) is characterized by two latent variables, \(\theta_i^{t,in}\) and \(\theta_i^{t,out}\), both of them evolving in time by following a covariance stationary autoregressive process \(AR(1)\):

\(\phantom{aaaaaaaaaaaaaaaaaaa} \theta_i^{t, in} = \varphi_{0,i}^{in} + \varphi_{1,i}^{in} \theta_i^{t-1, in} + \epsilon_i^{t, in}\),

\(\phantom{aaaaaaaaaaaaaaaaaaa} \theta_i^{t, out} = \varphi_{0,i}^{out} + \varphi_{1,i}^{out} \theta_i^{t-1, out} + \epsilon_i^{t, out},\)

where \(\varphi_{0,i}^{in}, \varphi_{0,i}^{out}\in \mathbb{R}\), \(|\varphi_{1,i}^{in}|, |\varphi_{1,i}^{out}|<1\), and i.i.d. normal innovations \(\epsilon_i^{t, in}\sim \mathcal{N}(0, {\sigma_i^{in}}^{2})\) and \(\epsilon_i^{t, out}\sim \mathcal{N}(0, {\sigma_i^{out}}^2)\).

Then, the observation equation for the network snapshot at time \(t\) is given by \(N(N-1)\) independent Bernoulli trials whose conditional probability is:

\(\phantom{aaaaaaaaaaaaaaaaaaa}\mathbb{P}(A^t| \Theta^t) = \prod_{j\neq i} \frac{e^{A^t_{ij}(\theta_i^{t, out} + \theta_j^{t, in})}}{1 + e^{\theta_i^{t, out} + \theta_j^{t, in}}},\)

where \(\Theta^t \equiv \{\theta_i^{t, in}, \theta_i^{t, out}\}_{i = 1, \dots, n}\).

Parameters:
  • n (integer) – Number of nodes in the graph.

  • T (integer) – Number of time snapshots.

  • theta_0_in (array) – Vector with the values of \({\theta_i^0}^{in}\). If it is set to ‘None’ the null vector is used. Default: ‘None’.

  • theta_0_out (array) – Vector with the values of \({\theta_i^0}^{out}\). If it is set to ‘None’ the null vector is used. Default: ‘None’.

  • phi_0_in (array) – Vector with the values of \({{\varphi_0}_i}^{in}\). If it is set to ‘None’ the vector of all 0.3 is used. Default: ‘None’.

  • phi_0_out (array) – Vector with the values of \({{\varphi_0}_i}^{out}\). If it is set to ‘None’ the vector of all 0.3 is used. Default: ‘None’.

  • phi_1_in (array) – Vector with the values of \({{\varphi_1}_i}^{in}\). If it is set to ‘None’ the vector of all 0.5 is used. Default: ‘None’.

  • phi_1_out (array) – Vector with the values of \({{\varphi_1}_i}^{out}\). If it is set to ‘None’ the vector of all 0.5 is used. Default: ‘None’.

  • sigma_in (array) – Vector with the values of \({{\sigma}_i}^{in}\). If it is set to ‘None’ the vector of all 0.3 is used. Default: ‘None’.

  • sigma_out (array) – Vector with the values of \({{\sigma}_i}^{out}\). If it is set to ‘None’ the vector of all 0.3 is used. Default: ‘None’.

Returns:

simulation: (list) Directed temporal network produced by a \(TGRG\) model.

Examples

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

Define input parameters

>>>    n = 50
>>>    T = 100

Simulate the temporal network

>>>   time_series = sm.tgrg_directed_simulation(n, T)

References