netneurotools.stats.network_variance

netneurotools.stats.network_variance(vec, D)[source]

Calculate variance of a vector on a graph.

Network variance is a measure of variance taken into account the network structure.

Warning

Test before use.

Parameters:
  • vec ((N,) array_like) – Input vector. Must be all positive. Will be normalized internally as a probability distribution.

  • D ((N, N) array_like) – Distance matrix.

Returns:

network_variance – Network variance of vec on D

Return type:

float

Notes

The network variance is defined as

\[var(p) = \frac{1}{2} \sum_{i, j} p(i) p(j) d^2(i,j)\]

where \(p\) is the probability distribution of vec, and \(d(i,j)\) is the distance between node \(i\) and \(j\).

The distance matrix \(D\) can make use of effective resistance or its square root.

Example using effective resistance as weight matrix

R_eff = effective_resistance(W)
netvar = network_variance(vec, R_eff)

References