sfa.utils module¶
-
sfa.utils.
rand_swap
(A, nsamp=10, noself=True, pivots=None, inplace=False)[source]¶ Randomly rewire the network connections by swapping.
- Parameters
- Anumpy.ndarray
Adjacency matrix (connection matrix).
- nsampint, optional
Number of sampled connections to rewire
- noselfbool, optional
Whether to allow self-loop link.
- pivotslist, optional
Indices of pivot nodes
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomized matrix. The reference of the given W is returned, when inplace is True.
-
sfa.utils.
rand_flip
(A, nsamp=10, pivots=None, inplace=False)[source]¶ Randomly flip the signs of connections.
- Parameters
- Anumpy.ndarray
Adjacency matrix (connection matrix).
- nsampint, optional
Number of sampled connections to be flipped.
- pivotslist, optional
Indices of pivot nodes
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomized matrix. The reference of the given W is returned, when inplace is True.
-
sfa.utils.
rand_weights
(W, lb=-3, ub=3, inplace=False)[source]¶ Randomly sample the weights of connections in W from 10^(lb, ub).
- Parameters
- Wnumpy.ndarray
Adjacency (connection) or weight matrix.
- lbfloat, optional
The 10’s exponent for lower bound
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomly sampled weight matrix. The reference of the given W is returned, when inplace is True.