Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
DSP Masters
DSP Masters am 28 Mär. 2012
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.

Antworten (1)

Tom Lane
Tom Lane am 28 Mär. 2012
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.

Kategorien

Mehr zu Random Number Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by