Create a two-point distribution?

조회 수: 7 (최근 30일)
kevin cecere palazzo
kevin cecere palazzo 2019년 10월 17일
댓글: kevin cecere palazzo 2019년 10월 17일
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?

답변 (1개)

dk
dk 2019년 10월 17일
N=100;
x=sign(rand(N,1)-0.5);
  댓글 수: 1
kevin cecere palazzo
kevin cecere palazzo 2019년 10월 17일
probability of getting sign(0)?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by