meanap.pipeline.null_models¶
Degree/strength-preserving network randomization, ports of
randmio_und_signed.m, null_model_und_sign.m, randmio_und_v2.m
and latmio_und_v2.m (BCT / Functions/CC_PL_SW/). The signed variants
are used by participation_coef_norm to normalize the participation
coefficient; randmio_und_v2/latmio_und_v2 build the random and
lattice-like null models that network_metrics.small_worldness_rl_wu
normalizes small-worldness against.
Not bit-reproducible against MATLAB — all four functions consume random numbers from MATLAB’s RNG, a different stream than Python’s. Same situation as Step 3’s thresholding and Step 4’s modularity: the algorithm is ported faithfully and validated via structural invariants (e.g. degree sequence is exactly preserved by construction), not by diffing against a specific MATLAB run’s specific random outcome.
Functions
|
Lattice-like degree-preserving null model, port of |
|
Randomize an undirected network, preserving degree and (approximately) strength distributions. |
|
Degree-preserving double-edge-swap randomization (Maslov & Sneppen 2002). |
|
Degree-preserving edge-swap null model, port of |
- meanap.pipeline.null_models.latmio_und_v2(w, iterations, d, rng=None)[source]¶
Lattice-like degree-preserving null model, port of
latmio_und_v2.m.dis the externally supplied “distance” matrix that biases which swaps count as more lattice-like — MEA-NAP passessquareform(pdist(adjM))(Euclidean distance between each node’s connectivity profile, not spatial electrode distance; seeExtractNetMet.m’s call site). Returns the latticized network in the original node ordering.- Parameters:
w (ndarray)
iterations (int)
d (ndarray)
rng (Generator | None)
- Return type:
ndarray
- meanap.pipeline.null_models.null_model_und_sign(w, bin_swaps=5, wei_freq=0.1, rng=None)[source]¶
Randomize an undirected network, preserving degree and (approximately) strength distributions.
Direct port of
null_model_und_sign.m’swei_freq < 1(periodic re-sort) branch — the default in modern MATLAB (nargin('randperm')~=1always true in any MATLAB version this codebase targets), so thewei_freq==1exact-resort branch isn’t ported.- Parameters:
w (ndarray)
bin_swaps (int)
wei_freq (float)
rng (Generator | None)
- Return type:
ndarray
- meanap.pipeline.null_models.randmio_und_signed(w, iterations, rng=None)[source]¶
Degree-preserving double-edge-swap randomization (Maslov & Sneppen 2002).
iterationsis a rewiring-attempts-per-edge multiplier, matching MATLAB’sITERinput: total swap attempts =iterations * n*(n-1)/2.- Parameters:
w (ndarray)
iterations (int)
rng (Generator | None)
- Return type:
ndarray
- meanap.pipeline.null_models.randmio_und_v2(w, iterations, rng=None)[source]¶
Degree-preserving edge-swap null model, port of
randmio_und_v2.m.Used to build the random null model that
network_metrics .small_worldness_rl_wunormalizes clustering coefficient and path length against.iterationsis a rewiring-attempts-per-edge multiplier, matching MATLAB’sITERinput.- Parameters:
w (ndarray)
iterations (int)
rng (Generator | None)
- Return type:
ndarray