How to create a sparse matrix obeying (-1,1) uniform distribution

I try to code

using SparseArrays
using Distributions

But it failed. So how to generate a sparse matrix obeying (-1,1) uniform distribution? Thanks

You need sprand rather than sprandn, and the last argument should be a function that maps n to a vector of n samples (though the docs don’t seem to say so anywhere).