small_world
ReservoirComputing.small_world — Function
small_world([rng], [T], dims...;
num_neighbors, rewiring_probability, radius=1.0, return_sparse=false)Create a reservoir whose connection topology follows the Watts-Strogatz small-world model. The initial ring lattice connects every node to num_neighbors neighbours; each clockwise edge is then rewired with probability rewiring_probability. Connection weights are sampled uniformly from $[-1, 1]$ before the matrix is scaled to the requested spectral radius.
Arguments
rng: Random number generator. Default isXoshiro(1234).T: Type of the elements in the reservoir matrix. Default isFloat32.dims: Dimensions of the reservoir matrix.
Keyword arguments
num_neighbors: Even number of neighbours for each node in the initial ring lattice. It must be at least two and smaller than the number of nodes.rewiring_probability: Probability in[0, 1]of rewiring each clockwise lattice edge.radius: Desired spectral radius of the reservoir. Defaults to 1.0.return_sparse: Flag for returning asparsematrix.truerequiresSparseArraysto be loaded. Default isfalse.
Examples
Create a ring lattice by disabling rewiring:
julia> reservoir_matrix = small_world(MersenneTwister(123), 5, 5;
num_neighbors = 2, rewiring_probability = 0.0);
julia> all(==(2), count(!iszero, reservoir_matrix; dims = 1))
trueRequest a sparse reservoir matrix:
julia> reservoir_matrix = small_world(MersenneTwister(123), 5, 5;
num_neighbors = 2, rewiring_probability = 0.5, return_sparse = true);
julia> reservoir_matrix isa SparseMatrixCSC{Float32} && size(reservoir_matrix) == (5, 5)
true