From: Barry W Brown on
On Nov 18, 4:21 am, "David Jones" <dajx...(a)ceh.ac.uk> wrote:
> steve wrote:
> > On Nov 16, 6:04 pm, frank <fr...(a)example.invalid> wrote:
> >> On Mon, 16 Nov 2009 16:05:14 -0800, steve 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.
>
> >> Isn't there an asymmetry in the unit interval though as to which
> >> endpoint is included? So if there's N outcomes on one side of .5
> >> there would be N +-1 on the other.
>
> > Can you restate your question without a little more detail?  
>
> <snip>
>
> The point centres on the explicit statement of the range in the standard as  0<= x < 1. Thus an exact value of zero is allowed as an output. while an exact value of one is not. So there is asymmetry on this point. For some uses, the question of whether or not exact zeroes and ones are ever returned is important and is sometimes addressed by testing for such values and re-generating another as necessary. Obviously such testing should be avoided if the zero or one case is guaranteed not to occur. Random number generators are such as to naturally include zero as a possible output, and to avoid this would involve slowing the code down.
>
> A description of a RNG should explicity state the range and discretisation of the values that might be reurned, so that it would be possible to see whether just rejecting zero values would leave the set of allowed values symmetric about zero.
>
> David Jones

Our library, RANDLIB has routines for uniform random numbers and
generators for all of
the common statistical distributions. It is available free for the
source download
from
http://biostatistics.mdanderson.org/SoftwareDownload
From: glen herrmannsfeldt on
Ron Shepard <ron-shepard(a)nospam.comcast.net> wrote:

> There are more floating point values between 0 and .5 than there are
> between .5 and 1. It is not just a difference of +-1 value. Should all
> such values occur in the pseudorandom sequence, or only a subset of such
> values?

Interesting question. In the days of 32 bit generators, ones I
knew just took 24 bits of the integer, added on the appropriate
exponent, maybe add zero to normalize it, and return. For IEEE
you can't do that, as it has the hidden one. Since most have
more state bits than significand bits it wouldn't be hard to
return the extra bits.

-- glen
From: David Flower on
On Nov 16, 9:58�pm, Marina <levin.mar...(a)gmail.com> wrote:
> 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.)
>
> Thanks,
> Marina

Posters may be interested in the following reference:

A.C.M. Trans. Math, Software, 5, #2, 132 (1979) by Linus Schrage

It is a random number generator that is machine and compiler
independent, useful for testing.

I cannot vouch for its efficiency or randomness.

If anyone is interested I will post a copy of the source code

Dave Flower
From: robin on
"David Jones" <dajxxxx(a)ceh.ac.uk> wrote in message news:4b03ca95$1(a)news.nerc-wallingford.ac.uk...

>The point centres on the explicit statement of the range in the standard as 0<= x < 1. Thus an exact value of zero is
>allowed as an output. while an exact value of one is not. So there is asymmetry on this point. For some uses, the
>question of whether or not exact zeroes and ones are ever returned is important and is sometimes addressed by testing
>for such values and re-generating another as necessary. Obviously such testing should be avoided if the zero or one
>case is guaranteed not to occur. Random number generators are such as to naturally include zero as a possible output,
>and to avoid this would involve slowing the code down.

But not by much, and probably wouldn't be noticed.


From: robin on
"glen herrmannsfeldt" <gah(a)ugcs.caltech.edu> wrote in message news:he274f$5ep$1(a)naig.caltech.edu...
| Ron Shepard <ron-shepard(a)nospam.comcast.net> wrote:
|
| > There are more floating point values between 0 and .5 than there are
| > between .5 and 1. It is not just a difference of +-1 value. Should all
| > such values occur in the pseudorandom sequence, or only a subset of such
| > values?
|
| Interesting question. In the days of 32 bit generators, ones I
| knew just took 24 bits of the integer, added on the appropriate
| exponent, maybe add zero to normalize it, and return. For IEEE
| you can't do that, as it has the hidden one.

Since you'd be using integer arithmetic to prepare the FPN,
the question of IEEE doesn't come into it.
And that applies to both cases.


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13
Prev: pointer and allocatable arrays
Next: f95 to windows dll