reservoirpy.mat_gen.bernoulli#

reservoirpy.mat_gen.bernoulli = <reservoirpy.mat_gen.Initializer (_bernoulli) object>[source]#

Create an array with values equal to either 1 or -1. Probability of success (to obtain 1) is equal to p.

Parameters:
  • *shape (int, int, ..., optional) – Shape (row, columns, …) of the array.

  • p (float, default to 0.5) – Probability of success (to obtain 1).

  • connectivity (float, default to 1.0) – Also called density of the sparse matrix. By default, creates dense arrays.

  • sr (float, optional) – If defined, then will rescale the spectral radius of the matrix to this value.

  • input_scaling (float or array, optional) – If defined, then will rescale the matrix using this coefficient or array of coefficients.

  • dtype (numpy.dtype, default to numpy.float64) – A Numpy numerical type.

  • sparsity_type ({"csr", "csc", "dense"}, default to "csr") – If connectivity is inferior to 1 and shape is only 2-dimensional, then the function will try to use one of the Scipy sparse matrix format (“csr” or “csc”). Else, a Numpy array (“dense”) will be used.

  • seed (optional) – Random generator seed. Default to the global value set with reservoirpy.set_seed().

  • degree (int, default to None) – If not None, override the connectivity argument and corresponds to the number of non-zero values along the axis specified by direction

  • direction ({"in", "out"}, default to "out") – If degree is not None, specifies the axis along which the degree non-zero values are distributed. - If direction is “in”, each line will have degree non-zero values. In other words, each node of the corresponding graph will have degree in-degrees - If direction is “out”, each column will have degree non-zero values. In other words, each node of the corresponding graph will have degree out-degrees

Returns:

If a shape is given to the initializer, then returns a matrix. Else, returns a function partially initialized with the given keyword parameters, which can be called with a shape and returns a matrix.

Return type:

Numpy array or callable