Random number generation [message #92664] |
Wed, 03 February 2016 08:51  |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
Folks,
Hi,
I am working on some simulation problems, that I need to generate random numbers. When I use>
print, mean(randomu(seed, 100000))
0.498516
print, mean(randomn(seed, 100000))
0.00100909
1-the randomn is much better than randomu. why is that?
2-I am expecting very small number for mean of this random numbers, but as you see they are quite big (i am expecting in order of 10e-7).
Is there any other way that i can use?
Thanks for anykind of helps...
Cheers,
Dave
|
|
|
Re: Random number generation [message #92665 is a reply to message #92664] |
Wed, 03 February 2016 09:48   |
lecacheux.alain
Messages: 325 Registered: January 2008
|
Senior Member |
|
|
Le mercredi 3 février 2016 17:51:13 UTC+1, dave poreh a écrit :
> Folks,
> Hi,
> I am working on some simulation problems, that I need to generate random numbers. When I use>
> print, mean(randomu(seed, 100000))
> 0.498516
> print, mean(randomn(seed, 100000))
> 0.00100909
> 1-the randomn is much better than randomu. why is that?
> 2-I am expecting very small number for mean of this random numbers, but as you see they are quite big (i am expecting in order of 10e-7).
> Is there any other way that i can use?
> Thanks for anykind of helps...
> Cheers,
> Dave
randomu generates a random N-vector, uniform in [0,1] with mean=0.5 and std(mean)= sqrt(1/12)/sqrt(N) about 0.001 in your case.
randomn generates a random gaussian N-vector with mean=0 and sigma=1; then std(mean) is 1/sqrt(N) about 0.003 in your case.
Everything is o.k.
alx.
|
|
|
Re: Random number generation [message #92666 is a reply to message #92664] |
Wed, 03 February 2016 16:38   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Wednesday, February 3, 2016 at 11:51:13 AM UTC-5, dave poreh wrote:
> Folks,
> Hi,
> I am working on some simulation problems, that I need to generate random numbers. When I use>
> print, mean(randomu(seed, 100000))
> 0.498516
> print, mean(randomn(seed, 100000))
> 0.00100909
> 1-the randomn is much better than randomu. why is that?
> 2-I am expecting very small number for mean of this random numbers, but as you see they are quite big (i am expecting in order of 10e-7).
> Is there any other way that i can use?
> Thanks for anykind of helps...
> Cheers,
> Dave
What kind of random numbers do you need? There are many kinds of random number distributions.
Alx is right, the average of a random sample will have some variance from the true average. They would not be random otherwise!
|
|
|
Re: Random number generation [message #92667 is a reply to message #92666] |
Thu, 04 February 2016 04:37   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Thursday, February 4, 2016 at 4:08:07 AM UTC+3:30, Craig Markwardt wrote:
> On Wednesday, February 3, 2016 at 11:51:13 AM UTC-5, dave poreh wrote:
>> Folks,
>> Hi,
>> I am working on some simulation problems, that I need to generate random numbers. When I use>
>> print, mean(randomu(seed, 100000))
>> 0.498516
>> print, mean(randomn(seed, 100000))
>> 0.00100909
>> 1-the randomn is much better than randomu. why is that?
>> 2-I am expecting very small number for mean of this random numbers, but as you see they are quite big (i am expecting in order of 10e-7).
>> Is there any other way that i can use?
>> Thanks for anykind of helps...
>> Cheers,
>> Dave
>
> What kind of random numbers do you need? There are many kinds of random number distributions.
>
> Alx is right, the average of a random sample will have some variance from the true average. They would not be random otherwise!
Hi Guys,
I am using Fortran for a radar data simulation...
The problem is: mean of these random numbers is increasing during the run (with changing of parameters), so the order of mean with different run is different. And that made me a problem...
BUT anyhow Alx is right, this is the nature of randomness...
Anyhow, thanks a lot :)
Cheers,
Dave
|
|
|
Re: Random number generation [message #92674 is a reply to message #92667] |
Thu, 04 February 2016 12:04  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Thursday, February 4, 2016 at 7:39:21 AM UTC-5, dave poreh wrote:
> On Thursday, February 4, 2016 at 4:08:07 AM UTC+3:30, Craig Markwardt wrote:
>> On Wednesday, February 3, 2016 at 11:51:13 AM UTC-5, dave poreh wrote:
>>> Folks,
>>> Hi,
>>> I am working on some simulation problems, that I need to generate random numbers. When I use>
>>> print, mean(randomu(seed, 100000))
>>> 0.498516
>>> print, mean(randomn(seed, 100000))
>>> 0.00100909
>>> 1-the randomn is much better than randomu. why is that?
>>> 2-I am expecting very small number for mean of this random numbers, but as you see they are quite big (i am expecting in order of 10e-7).
>>> Is there any other way that i can use?
>>> Thanks for anykind of helps...
>>> Cheers,
>>> Dave
>>
>> What kind of random numbers do you need? There are many kinds of random number distributions.
>>
>> Alx is right, the average of a random sample will have some variance from the true average. They would not be random otherwise!
>
> Hi Guys,
> I am using Fortran for a radar data simulation...
> The problem is: mean of these random numbers is increasing during the run (with changing of parameters), so the order of mean with different run is different. And that made me a problem...
> BUT anyhow Alx is right, this is the nature of randomness...
But you have to know what kind of random number distribution is required! RANDOMU() produces uniform deviates. RANDOMN() produces gaussian deviates. They are completely different.
|
|
|