Prev: pointer and allocatable arrays
Next: f95 to windows dll
From: robin on 17 Nov 2009 03:53 "Marina" <levin.marina(a)gmail.com> wrote in message news:94929b54-dacb-4d20-9187-a988c48d5848(a)m13g2000vbf.googlegroups.com... | Hi, | | I have a question regarding the subroutine RANDOM_NUMBER, | does it generate a list of uniformly distributed numbers, between 0 | and 1, and an average of 0.5? | | Which other intrinsic random number generating subroutines are | available for Fortran 90, for other distributions? | (I found that the function rand() doesn't work in my compiler, for | example.) Rand is not a standard function.
From: Gordon Sande on 17 Nov 2009 09:41 On 2009-11-16 20:05:14 -0400, steve <kargls(a)comcast.net> said: > On Nov 16, 1:58�pm, Marina <levin.mar...(a)gmail.com> wrote: >> >> I have a question regarding the subroutine RANDOM_NUMBER, >> does it generate a list of uniformly distributed numbers, between 0 >> and 1, and an average of 0.5? > > The description for RANDOM_NUMBER is given in 13.14.85 of the > Fortran 95 standard. It states > > Description. Returns one pseudorandom number or an array of > pseudorandom numbers from the uniform distribution over the > range 0 <= x < 1. > > Note, it says nothing about an average of 0.5. If you only draw 2 > values from the distribution is highly unlikely that the average is > 0.5. OTOH, if you draw hundred or thousands or millions of samples, > then the average will be near 0.5. The standard is even less demanding than that as it says absolutely nothing about the quality of the random numbers. If it always returned 0.33 it would be standard conforming and under some definitions of randomness as surprise it would even be of high quality because such a sequence would be highly surprising. ;-) It would surely draw many user complaints about the poor quality of implementation. There is a common issue about whether the sequence should always default to the same one for ease of debugging or should it be "random". >> Which other intrinsic random number generating subroutines are >> available for Fortran 90, for other distributions? > > The Fortran standard requires that a comforming compiler must > supply RANDOM_NUMBER. Vendors can choose to supply additional > random number generators, so check your documentation. > Note, there are numerous Fortran implementations of PRNG. Try > searching on 'metcalf KISS' and 'ranlux' to name just two. There > are others. As always, you should test whatever PRNG you choose > to determine if it is adequate for your application.
From: steve on 17 Nov 2009 10:13 On Nov 17, 6:41 am, Gordon Sande <g.sa...(a)worldnet.att.net> wrote: > There is a common issue about whether the sequence should always > default to the same one for ease of debugging or should it be "random". I'm well aware of this issue because I'm the person that decided gfortran should default to a given sequence if one does not call random_seed. I made this decision precisely as you state "for the ease of debugging." -- steve
From: Gordon Sande on 17 Nov 2009 10:20 On 2009-11-17 11:13:29 -0400, steve <kargls(a)comcast.net> said: > On Nov 17, 6:41�am, Gordon Sande <g.sa...(a)worldnet.att.net> wrote: > >> There is a common issue about whether the sequence should always >> default to the same one for ease of debugging or should it be "random". > > I'm well aware of this issue because I'm the person that decided > gfortran should default to a given sequence if one does not call > random_seed. I made this decision precisely as you state "for the > ease of debugging." The only folks who I have heard question such a choice are beginners who are surprised when the random sequence is always the same on their successive runs (that are often for debugging :-( ). It was not really fair to call it an issue even if it does confuse a few beginners.
From: nmm1 on 17 Nov 2009 10:37
In article <2009111711204716807-gsande(a)worldnetattnet>, Gordon Sande <g.sande(a)worldnet.att.net> wrote: >On 2009-11-17 11:13:29 -0400, steve <kargls(a)comcast.net> said: >> >>> There is a common issue about whether the sequence should always >>> default to the same one for ease of debugging or should it be "random". >> >> I'm well aware of this issue because I'm the person that decided >> gfortran should default to a given sequence if one does not call >> random_seed. I made this decision precisely as you state "for the >> ease of debugging." > >The only folks who I have heard question such a choice are beginners >who are surprised when the random sequence is always the same on their >successive runs (that are often for debugging :-( ). It was not really >fair to call it an issue even if it does confuse a few beginners. Then try me. I am one of the experts who takes the converse view, on the grounds of statistical validity. In particular, using the same numbers to test two related analyses gives erroneous results if you compare the analyses statistically assuming independence. A classic error of scientists who ought to know better. However, I accept that it is a matter of judgement which choice will lead to more wrong answers, overall. Regards, Nick Maclaren. |