brainevent.jitn#
- brainevent.jitn = <NameScope(brainevent.jitn)>#
Materialise a JIT normally-distributed random connectivity matrix.
Generates a dense matrix of shape shape (or its transpose) where each element is drawn from
Normal(w_loc, w_scale)with independent Bernoulli masking at probability prob.- Parameters:
w_loc (scalar or Quantity) – Mean of the normal weight distribution.
w_scale (scalar or Quantity) – Standard deviation of the normal weight distribution. Must have the same physical unit as w_loc.
prob (float) – Connection probability in
[0, 1].seed (int) – RNG seed for reproducible connectivity.
shape (tuple of int) – Logical matrix shape
(n_pre, n_post).transpose (bool, optional) – If
True, return the transposed matrix of shape(n_post, n_pre). Default isFalse.corder (bool, default=True) – Which index owns a random stream.
True: one stream per output row, walked over the input (a gather, no atomics).False: one stream per input index, scattered into the output (zero inputs are skipped). The two values draw different matrices;transpose=True, corder=not cuses exactly the transpose of the matrix drawn bytranspose=False, corder=c.backend (str or None, optional) – Compute backend (e.g.
'numba','pallas').
- Returns:
Dense matrix of shape
shape(orshape[::-1]when transpose isTrue).- Return type:
jax.Array or Quantity
- Raises:
ValueError – If
probis not a scalar, is not finite, or is outside[0, 1].
See also
Notes
Each entry
W[i, j]of the generated matrix follows the model:W[i, j] = N(w_loc, w_scale) * B[i, j]where
N(w_loc, w_scale)is a draw from a normal distribution andB[i, j] ~ Bernoulli(prob)is a binary mask. Equivalently:W[i, j] ~ Normal(w_loc, w_scale)with probabilityprobW[i, j] = 0with probability1 - prob
The expected value of each entry is
E[W[i, j]] = prob * w_loc.The connectivity pattern and normal variates are fully determined by
seedandprob. Using the sameseedalways produces the same matrix.This function materialises the full dense matrix. For implicit (non-materialised) products, use
jitnmv()orjitnmm().Examples
>>> import jax.numpy as jnp >>> from brainevent._jit_normal.float import jitn >>> W = jitn(0.0, 1.0, prob=0.1, seed=42, shape=(100, 50)) >>> W.shape (100, 50)