Why are there repeated values from EXPRND?
古いコメントを表示
I'm generating several hundred values from EXPRND with a given eta parameter, which I'm using to populate an array, which I then use in subsequent processing, finding the minimum value through several iterations of loops, comparing it to the value of other variables, blah blah blah, and replacing that minimum value with other generated values of of EXPRND as necessary. Regardless, I'm using the following command to find the location of the minimum value in my array:
[x,y]=ind2sub(size(array),find(array==min(min(array))));
This works perfectly well, however, the problem is that it will often find instances where there are TWO locations in my large array that have IDENTICAL values, which happen to be the minimum value in the array at that moment in the simulation, which then causes an error when I try to do anything with the (x,y) coordinates I thought I've created, because of dimensional errors, because I'm passing multiple arguments to functions when they're expecting singular arguments, for instance array(x,y)=SOMETHING...
How can it be possible that a random number generator with double precision would produce TWO identical values, which has now occurred on eight consecutive executions of my simulation, even on different machines, no matter if I restart the program or not? I am perplexed...
2 件のコメント
Andrew Newell
2012 年 1 月 27 日
I'm not able to reproduce this with several trials involving 100 million values:
array = exprnd(1,[10000 10000]);
What values of mu has this problem occurred for?
Matt Opitz
2012 年 1 月 28 日
採用された回答
その他の回答 (4 件)
Peter Perkins
2012 年 1 月 27 日
This is certainly possible for very extreme values of the mean parameter, because the "correct" values saturate to zero or Inf:
>> exprnd(eps(realmin),3)
ans =
0 4.9407e-324 4.9407e-324
0 4.9407e-324 9.8813e-324
4.9407e-324 1.4822e-323 9.8813e-324
>> exprnd(realmax,3)
ans =
Inf 1.8399e+307 1.2851e+308
1.5712e+308 1.021e+307 Inf
Inf 1.2792e+308 1.893e+307
But that's rather extreme. I think you're going to have to provide an example.
Peter Perkins
2012 年 2 月 1 日
Matt, I am confused. You seem to be saying something roughly equivalent to, "I generated a few hundred values using exprnd(8714,n,1), and the minimum value was around 6487, and there were multiple occurrences of that value." Putting aside the question of non-unique values for a moment, when I generate a few hundred values like that, repeatedly, my minimum values are much smaller:
>> x = exprnd(8714,300,10000);
>> quantile(min(x,[],1),[.01 .05 .25 .5 .75 .95 .99])
ans =
0.28872 1.389 8.2665 20.169 40.089 86 137.22
So somehow we're not on the same page at all. I may be completely misunderstanding what you're saying. I confess that I am unable to understand your description of how you are filling in the array. But it seems like if exprnd is at fault here, you should be able to demonstrate that in a single line of code such as
min(exprnd(8714,n,1))
or
length(unique(exprnd(8714,n,1)))
What do you get from those?
And what do you get from
which rand
which exprnd
Matt Opitz
2012 年 2 月 1 日
0 投票
2 件のコメント
Matt Opitz
2012 年 2 月 1 日
Walter Roberson
2012 年 2 月 1 日
Perhaps you could record the state information of the random number generator at the appropriate point in the code, and when you detect that condition happening, dump out the state so that the behavior could be replicated more easily?
Peter Perkins
2012 年 2 月 1 日
0 投票
Matt, without some concrete way to reproduce this, I don't know what to say.
It sounds like what you're saying is that you create an array of random values, and then somehow overwrite the smallest values with something not randomly generated, iteratively, so that eventually you are left with an array whose smallest randomly generated value left is 6487.2 because all the smaller randomly generated values have already been overwritten.
Something like Walter's suggestion might be a way to solve this. Perhaps you could save the random number generator state at the beginning of your simulation ("s = rng"), and then find a repeated value. Then reset to the original state ("rng(s)") and start generating arrays of exp(8714) values until you find that same value occurring twice in the stream. Keep track of the places it occurred.
By the way, if you're changing the 8714 during this simulation to something else, then all bets are off.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!