brainevent.jitu

Contents

brainevent.jitu#

brainevent.jitu = <NameScope(brainevent.jitu)>#

Materialize a JIT uniform connectivity matrix as a dense array.

Generates a dense matrix where each entry is drawn from Uniform(w_low, w_high) at positions determined by the connection probability prob and random seed seed. All other entries are zero.

Parameters:
  • w_low (Array | ndarray | Quantity | Number) – Lower bound of the uniform weight distribution. Scalar value, optionally with physical units (brainunit.Quantity).

  • w_high (Array | ndarray | Quantity | Number) – Upper bound of the uniform weight distribution. Must have the same dimension (units) as w_low.

  • prob (float) – Connection probability in [0, 1]. Determines the fraction of non-zero entries in the generated matrix.

  • seed (int) – Random seed for reproducible connectivity and weight generation.

  • shape (Tuple[int, int]) – Shape (m, n) of the output matrix.

  • transpose (bool) – If True, generate the transposed matrix of shape (n, m). Default is False.

  • corder (bool) – Memory layout order for the connectivity generation. True for C-order (row-major), False for Fortran-order (column-major). Default is True.

  • backend (str | None) – Computation backend. One of 'numba' or 'pallas'. If None, the default backend is used.

Returns:

Dense matrix of shape (m, n) (or (n, m) if transpose=True) with uniformly distributed weights at connected positions and zeros elsewhere. Carries physical units if w_low has units.

Return type:

Array | ndarray | Quantity | Number

See also

jitumv

Matrix-vector product without materializing the matrix.

Notes

Each entry A[i, j] of the generated matrix follows the model:

A[i, j] = U[i, j] * B[i, j]

where U[i, j] ~ Uniform(w_low, w_high) and B[i, j] ~ Bernoulli(prob) are independent random variables. Equivalently:

  • A[i, j] ~ Uniform(w_low, w_high) with probability prob

  • A[i, j] = 0 with probability 1 - prob

The expected value of each entry is:

E[A[i, j]] = prob * (w_low + w_high) / 2

The connectivity pattern and uniform variates are determined by seed and prob. Using the same seed always produces the same matrix.

This function materializes the full dense matrix. For implicit (non-materialized) matrix-vector products, use jitumv() or jitumm() instead.

Examples

>>> import jax.numpy as jnp
>>> from brainevent._jit_uniform.float import jitu
>>> dense = jitu(0.1, 0.5, 0.2, seed=42, shape=(4, 6))
>>> dense.shape
(4, 6)