From: cubsfan on
Hi,

I've been working with astroparticle simulations using fortran, and I
need to call random numbers. However, they need to be of a
significant distance away from zero, in particular 2E16 or greater.
Is there anyway to set a parameter with the 'random_number' command --
ie specify between what numbers the random one is generated?

Thanks
From: Gus Gassmann on
cubsfan wrote:
> Hi,
>
> I've been working with astroparticle simulations using fortran, and I
> need to call random numbers. However, they need to be of a
> significant distance away from zero, in particular 2E16 or greater.
> Is there anyway to set a parameter with the 'random_number' command --
> ie specify between what numbers the random one is generated?

What else do you know about the distribution? It seems exceedingly
unlikely that you'd have a uniform distribution under the circumstances.
So you will need to use a transformation; the exact form will depend on
the information you have about the random variable you want to model.
From: e p chandler on

"cubsfan" <cubsfan334(a)gmail.com> wrote in message
news:3195d648-18d7-442e-9f94-d4be74f94f25(a)q27g2000yqn.googlegroups.com...
> Hi,
>
> I've been working with astroparticle simulations using fortran, and I
> need to call random numbers. However, they need to be of a
> significant distance away from zero, in particular 2E16 or greater.
> Is there anyway to set a parameter with the 'random_number' command --
> ie specify between what numbers the random one is generated?
>
> Thanks

random_number returns numbers uniformly distributed between zero and one
(one excluded). It is easy enough to scale these to a uniform distribution
over a particular range by linear interpolation. However you have not
specified the probability model you are using for your random draws or what
quantity you are simulating.

--- e



From: Sjouke Burry on
cubsfan wrote:
> Hi,
>
> I've been working with astroparticle simulations using fortran, and I
> need to call random numbers. However, they need to be of a
> significant distance away from zero, in particular 2E16 or greater.
> Is there anyway to set a parameter with the 'random_number' command --
> ie specify between what numbers the random one is generated?
>
> Thanks
2e16*(1+rand())
From: Richard Maine on
Sjouke Burry <burrynulnulfour(a)ppllaanneett.nnll> wrote:

> cubsfan wrote:
> >
> > I've been working with astroparticle simulations using fortran, and I
> > need to call random numbers. However, they need to be of a
> > significant distance away from zero, in particular 2E16 or greater.
> > Is there anyway to set a parameter with the 'random_number' command --
> > ie specify between what numbers the random one is generated?
> >
> > Thanks
> 2e16*(1+rand())

There is a standard Fortran random number intrinsic. Rand is not it. As
the OP mentions, it is random_number. (Well, it isn't a "command", but
that's a bit nitpicky). Since he already has that part right, I see no
benefit in pointing him towards a nonportable, nonstandard form.

I'd also second Gus's comment that one would need to have at least some
further clue as to what kind of distribution was desired in order to
give a good answer.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain