Equal probability in 'randsrc(m,n)' in-built function

조회 수: 2 (최근 30일)
DSP Masters
DSP Masters 2012년 3월 28일
Hi, we have an in-built function called 'randsrc(m,n)', where ideally it should generate an m-by-n matrix, each of whose entries independently takes the value -1 with probability 1/2, and 1 with probability 1/2.
Problem: I have used randsrc(1,3072), where I should get number of +1's and -1's as 1536 each.I am not getting equal number of +1's and -1's
Please help me in finding out the solution for this.
Regards, Sowmya.

답변 (1개)

Tom Lane
Tom Lane 2012년 3월 28일
I have no idea what your function is or if it does things correctly. But from your description you would not expect exactly 1536 +1's each time. The number should vary according to a binomial distribution. Otherwise your values are not independent or not random.
If you have the Statistics Toolbox, there are function with names starting with "bino" that you might use to help decide if your results are reasonable. For example, here is an interval that you'd expect to contain roughly 98% of the values:
>> binoinv([.01 .99],3072,.5)
ans =
1472 1600
The standard deviation of the result should be about sqrt(3072/4) = 27.7.

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by