フィルターのクリア

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 Center および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by