networksns.statistical_models.tgrg_simulation¶
- networksns.statistical_models.tgrg_simulation(n, T, theta_0=None, phi_0=None, phi_1=None, sigma=None)¶
Simulate a temporal network following the Temporally Generalized Random Graph model (\(TGRG\)).
For the \(TGRG\) model [1], with temporal network represented by a time series of adjacency matrices \(\{A_{ij}^t\}_{i,j=1,\ldots, n}^{t=1,\ldots,s}\), each node \(i\) is described by a latent variable \(\theta_i^t\), namely the fitness of the node, which evolves over time by following a covariance stationary autoregressive process \(AR(1)\):
\(\phantom{aaaaaaaaaaaaaaaaaaa}\theta_i^t = \varphi_{0,i} + \varphi_{1,i} \theta_i^{t-1} + \epsilon_i^t\),
with \(\varphi_{0,i}\in \mathbb{R}\), \(|\varphi_{1,i}|<1\), and i.i.d. normal innovations \(\epsilon_i^t\sim \mathcal{N}(0, \sigma_i^2)\). Then, the observation equation for the network snapshot at time \(t\) is given by \(\binom{N}{2}\) independent Bernoulli trials whose conditional probability is:
\(\phantom{aaaaaaaaaaaaaaaaaaa}\mathbb{P}(A^t| \Theta^t) = \prod_{i<j} \frac{e^{A^t_{ij}(\theta_i^t + \theta_j^t)}}{1 + e^{\theta_i^t + \theta_j^t}}\),
with \(\Theta^t \equiv \{\theta_i^t\}_{i = 1, \dots, n}\).
- Parameters:
n (integer) – Number of nodes in the graph.
T (integer) – Number of time snapshots.
theta_0 (array) – Vector with the values of \(\theta_i^0\). If it is set to ‘None’ the null vector is used. Default: ‘None’.
phi_0 (array) – Vector with the values of \({\varphi_0}_i\). If it is set to ‘None’ the vector of all 0.3 is used. Default: ‘None’.
phi_1 (array) – Vector with the values of \({\varphi_1}_i\). If it is set to ‘None’ the vector of all 0.5 is used. Default: ‘None’.
sigma (array) – Vector with the values of \({\sigma}_i\). If it is set to ‘None’ the vector of all 0.3 is used . Default: ‘None’.
:param : Temporal network produced by a \(TGRG\) model. :type : return: simulation: (list)
Examples
>>> from networksns import statistical_models as sm >>> import numpy as np
Define input parameters
>>> n = 60 >>> T = 150 >>> phi_0 = np.ones(n) * 0.2 >>> phi_1 = np.ones(n) * 0.6
Simulate the temporal network
>>> time_series = sm.tgrg_simulation(n, T, phi_0=phi_0, phi_1=phi_1)