Equal probability in 'randsrc(m,n)' in-built function
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!