event_mv_prob_normal

event_mv_prob_normal#

class brainpy.math.jitconn.event_mv_prob_normal(events, w_mu, w_sigma, conn_prob, seed=None, *, shape, transpose=False, outdim_parallel=True)[source]#

Perform the \(y=M@v\) operation, where \(M\) is just-in-time randomly generated with a normal distribution for its value.

This operator support jit(), vmap(), grad() and pmap() etc. transformations on CPU and GPU devices.

Warning

This API may change in the future.

In this operation, \(M\) is the random matrix with a connection probability conn_prob, and at each connection the value is the same scalar weight.

When transpose=True, we perform an operation of \(y=M^T@v\).

Note

Note that the just-in-time generated \(M\) (transpose=False) is different from the generated \(M^T\) (transpose=True).

If you pursue the same \(M\) and \(M^T\) when performing the just-in-time matrix generation, you should set outdim_parallel=True, with the sacrifice of the speed compared with outdim_parallel=False.

Parameters:
  • vector (Array, ndarray) – The vector.

  • w_mu (float) – Mean (centre) of the distribution.

  • w_sigma (float) – Standard deviation (spread or “width”) of the distribution. Must be non-negative.

  • conn_prob (float) – The connection probability.

  • shape (Tuple[int, int]) – The matrix shape.

  • seed (Optional[int]) –

    The random number generation seed.

    Warning

    If seed is left as None (the default), a host random seed is drawn with numpy.random.randint on every call. This makes the result non-reproducible in eager mode, and – because the seed is captured as a Python constant – it becomes frozen the first time the function is traced under jit()/vmap(), so every subsequent jitted call reuses that single seed. For reproducible and correct behaviour under JAX transformations, always pass an explicit integer seed.

  • transpose (bool) – Transpose the random matrix or not.

  • outdim_parallel (bool) – Perform the parallel random generations along the out dimension or not. It can be used to set the just-in-time generated :math:M^T: is the same as the just-in-time generated \(M\) when transpose=True.

Returns:

out – The output of \(y = M @ v\).

Return type:

Array