From: William Clodius on
cubsfan <cubsfan334(a)gmail.com> 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

Where to begin? If you have to ask this sort of question it is likely
you are in over your head. What do you mean by an astroparticle? I aam
less worried if this is for a game than if it is for research. What is
the distribution of interest? Uniform, Gaussian, poisson, exponential,
...., one dimensional, two dimensional, three dimensional, ...,
spherically symmetric, cubic symmetry, ...? How concerned do you have to
be about consecutive samples? How fine a sampling do you need, which is
related to how many samples are you going to take?

--
Bill Clodius
los the lost and net the pet to email
From: cubsfan on
Sorry, I should have clarified: this is for a school physics project,
not formal research. I would think that I would want a uniform
distribution (I'm in high school, I don't know a whole lot about
statistics) although I don't think that matters too much. I simply
need the program to generate a random number (or pseudorandom number,
I don't care) between -2E16 and 2E16, and I'll have the program repeat
that probably up to 1,000 times. Sjouke's suggestion of using
random_number and multiplying by 2E16 would work fine, I think, except
all the numbers would be positive.
From: tholen on
cubsfan <cubsfan334(a)gmail.com> writes:

> Sorry, I should have clarified: this is for a school physics project,
> not formal research. I would think that I would want a uniform
> distribution (I'm in high school, I don't know a whole lot about
> statistics) although I don't think that matters too much. I simply
> need the program to generate a random number (or pseudorandom number,
> I don't care) between -2E16 and 2E16, and I'll have the program repeat
> that probably up to 1,000 times. Sjouke's suggestion of using
> random_number and multiplying by 2E16 would work fine, I think, except
> all the numbers would be positive.

If so, then simply multiply by 4E16 and then subtract 2E16.

From: e p chandler on

"cubsfan" <cubsfan334(a)gmail.com> wrote in message
news:83e813e6-c7d9-48d9-a2ba-fee3d2658e96(a)l26g2000yqd.googlegroups.com...
> Sorry, I should have clarified: this is for a school physics project,
> not formal research. I would think that I would want a uniform
> distribution (I'm in high school, I don't know a whole lot about
> statistics) although I don't think that matters too much.

It's a good opportunity to learn about statistics. Try your "experiment"
with a different statistical distribution, and see what happens. Then try to
explain why.

> I simply
> need the program to generate a random number (or pseudorandom number,
> I don't care) between -2E16 and 2E16, and I'll have the program repeat
> that probably up to 1,000 times. Sjouke's suggestion of using
> random_number and multiplying by 2E16 would work fine, I think, except
> all the numbers would be positive.

Just draw a second random number, U2. If U2 < 0.5 then U1=-U1. Why does this
work?

But if you want to be tricky, then if U is your uniform random on [0,1), 2*U
is uniform on [0,2), 2*U-1 is uniform on [-1,1), so 2E16*(2*U-1) is uniform
on [-2E16,2E16).

Note that there are entire chapters in statistics textbooks devoted to
transforming random variables!

--- e






From: steve on
On Feb 13, 2:32 am, tho...(a)antispam.ham wrote:
> cubsfan <cubsfan...(a)gmail.com> writes:
> > Sorry, I should have clarified: this is for a school physics project,
> > not formal research.  I would think that I would want a uniform
> > distribution (I'm in high school, I don't know a whole lot about
> > statistics) although I don't think that matters too much.  I simply
> > need the program to generate a random number (or pseudorandom number,
> > I don't care) between -2E16 and 2E16, and I'll have the program repeat
> > that probably up to 1,000 times.  Sjouke's suggestion of using
> > random_number and multiplying by 2E16 would work fine, I think, except
> > all the numbers would be positive.
>
> If so, then simply multiply by 4E16 and then subtract 2E16.

The subtraction of two large number can lead to catastrophic
cancellation, which may lead to some undesired bias in the
final sequence. It might be better to multiply the result
of random_number by 2 and then subtraction 1, and then multiply
by 2e16.


--
steve
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: Different Views of 3d matrix
Next: OPEN error inconsistent