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

latmio_und_v2(w, iterations, d[, rng])

Lattice-like degree-preserving null model, port of latmio_und_v2.m.

null_model_und_sign(w[, bin_swaps, ...])

Randomize an undirected network, preserving degree and (approximately) strength distributions.

randmio_und_signed(w, iterations[, rng])

Degree-preserving double-edge-swap randomization (Maslov & Sneppen 2002).

randmio_und_v2(w, iterations[, rng])

Degree-preserving edge-swap null model, port of randmio_und_v2.m.

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.

d is the externally supplied “distance” matrix that biases which swaps count as more lattice-like — MEA-NAP passes squareform(pdist(adjM)) (Euclidean distance between each node’s connectivity profile, not spatial electrode distance; see ExtractNetMet.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’s wei_freq < 1 (periodic re-sort) branch — the default in modern MATLAB (nargin('randperm')~=1 always true in any MATLAB version this codebase targets), so the wei_freq==1 exact-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).

iterations is a rewiring-attempts-per-edge multiplier, matching MATLAB’s ITER input: 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_wu normalizes clustering coefficient and path length against. iterations is a rewiring-attempts-per-edge multiplier, matching MATLAB’s ITER input.

Parameters:
  • w (ndarray)

  • iterations (int)

  • rng (Generator | None)

Return type:

ndarray