Create a two-point distribution?

4 views (last 30 days)
kevin cecere palazzo
kevin cecere palazzo on 17 Oct 2019
I want to multiply each element of a vector by a random variable X that takes values +1 and -1 with probability 1/2. How do I create this random variable?

Answers (1)

dk
dk on 17 Oct 2019
N=100;
x=sign(rand(N,1)-0.5);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!