Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Allie
 
Posts: n/a
Default Non-random numbers generated by excel's data analysis random gener

Hi,

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an extremely
unlikely circumstance with a true RN generator. I just wanted to raise this
flag, as it could be affecting others without their knowledge.

Thanks,
Allie

  #2   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

Copy this formula down

=INT(RAND()*(10-1)+1)

--
Regards,

Peo Sjoblom

(No private emails please)


"Allie" wrote in message
...
Hi,

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able
to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an extremely
unlikely circumstance with a true RN generator. I just wanted to raise
this
flag, as it could be affecting others without their knowledge.

Thanks,
Allie


  #3   Report Post  
Allie
 
Posts: n/a
Default

Thanks for your reply, Peo. I'm not looking for a workaround (which I've
already figured out), I'm interested in letting people, and microsoft, know
about this bug.

Thanks,
Allie
  #4   Report Post  
Mike Middleton
 
Posts: n/a
Default

Allie -

See "Description of the effects of the improved statistical functions for
the Analysis ToolPak in Excel 2003 and in Excel 2004 for Mac," at

http://support.microsoft.com/default...b;en-us;829208

specifically, the "Random Number Generation" section.

- Mike
www.mikemiddleton.com

"Allie" wrote in message
...
Hi,

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able
to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an extremely
unlikely circumstance with a true RN generator. I just wanted to raise
this
flag, as it could be affecting others without their knowledge.

Thanks,
Allie



  #5   Report Post  
 
Posts: n/a
Default

Allie wrote:

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an extremely
unlikely circumstance with a true RN generator.


Not at all.

First, because you are seeding the RNG, it is not
"a true RNG" at all. The sequence is predictable
and repeatable, which is your intention.

Second, if we knew the RNG algorithm, it might not
be surprising at all that a low seed (1 to 10) might
generate a very low number initially, perhaps even
the lowest value a small set (16) of numbers.

In fact, if you increase the set to 100 with a seed
of 10, the first number is not the smallest. The
same is true of a set of 16 numbers if you choose a
large seed, e.g. 10000.

MS Excel documentation should offer some guidance for
choosing a seed. It can greatly affect not only the
range of numbers generated, but also the apparent
randomness (distribution over the range) of at least
the first small set of numbers. I do not find any
such guidance in the Help text.

In any case, all of this is common to all RNGs. An
RNG simply uses a recursive mathematical formula.
For example, a linear congruential method might use
the formula X[n+1] = (a*X[n] + c) mod m, where X[0]
is the seed or a deterministic function of the seed
(apparently the latter for the ATP RNG, since its
seed must be an integer), and a, c and m are chosen
by the RNG designer, hopefully based on the plethora
of research literature on the subject. For an
introduction, see Knuth, Art of Computer Programming,
vol 2 (Seminumerical Algorithms).

I hope this gives you some insight into your observation.
If it bothers you (I don't know why it would), choose
a different seed or generate a larger set of numbers.



  #6   Report Post  
 
Posts: n/a
Default

Peo Sjoblom wrote:
"Allie" wrote:
I'm using Uniform number generation between 0 and 1,
and I am using a random seed, as I would like to be
able to re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16
cells with random numbers


Copy this formula down
=INT(RAND()*(10-1)+1)


Obviously you do not understand what a "seed" is for an
RNG.

Allie is not trying to generate random integers between
1 and 10, which your expression does. In fact, she said
she wants to generate random real numbers between 0 and 1.

A "seed" is a value that is used to initialize an RNG
so that the sequence is repeatable -- as Allie said.
Your expression generates a non-repeatable sequence of
numbers -- hopefully ;-).

  #7   Report Post  
D Hilberg
 
Posts: n/a
Default

Anyone who still uses numerical methods to generate random numbers is
living in a state of sin.

(according to John von Neuman)

- D Hilberg

(Have you tried measuring the decay of a radioactive element?)

  #8   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default

D Hilberg wrote:

Anyone who still uses numerical methods to generate random numbers is
living in a state of sin.

(according to John von Neuman)

- D Hilberg

(Have you tried measuring the decay of a radioactive element?)



And you measure the decay of radioactive elements from your living room how?

pRNG algorithms have progressed greatly since von Neumann's time. Excel
2003's RAND(), which is a vast improvement, is still two decades out of
date. The Mersenne Twister is quite a good pRNG

http://www.math.sci.hiroshima-u.ac.j...at/MT/emt.html
http://www.math.sci.hiroshima-u.ac.j...S/FORTRAN/fort...
http://www-personal.engin.umich.edu/...neTwister.html

which is implemented in the freeware NtRand

http://www.numtech.com/NtRand/

Jerry

  #9   Report Post  
 
Posts: n/a
Default

D Hilberg wrote:
Anyone who still uses numerical methods to generate random
numbers is living in a state of sin.
[....]
(Have you tried measuring the decay of a radioactive element?)


At the risk of giving credance to what might have been
intended as levity ....

Yes, there are hardware-based RNGs. These are becoming
common-place on "mainframes" (technical computers). They
might be available as add-ons for PCs. I did not think
they are commonly built into PCs, though. Are they?

In any case, the OP asked about a seeded RNG. By
definition, a seeded RNG is deterministic (repeatable),
not "random" at all (although we hope a large sampling
has the appearance of "randomness"). And whether you
rely hardware or software, the first number of a seeded
RNG will depend on the seed, by definition.

The purpose of my posting was to provide a basic
understanding of seeded RNGs so that the OP could
understand why the first number in a small sampling
__might__ "always" be the smallest value, without the
illusion of a defect. And in fact, my point was: it
will __not__ always be the smallest, if you choose
either the seed or the sample size appropriately.

  #10   Report Post  
David J. Braden
 
Posts: n/a
Default

Hey Mike!
OK, OK, others interested in this kind of stuff---
The link http://support.microsoft.com/kb/828795 glosses over Excel's latest
incarnation of RAND()

(1) We now have a doc of what MS intends. Can anyone map back into the longs
from doubles to run the PRNG through Marsaglia's DIEHARD? (I can't) The
coders might be trying to fix a long established problem (I started
complaining in 1985). Do we *know* that they actually implemented what they
intended this last go-round (as opposed to what shipped with Excel 11) with
the latest SP? Also, *when* will they get a seed into the thing? (see note)

(2) Microsoft's note re ATP PRNG is absolute BS. Generate a few thousand
variates, and you will see repeats, including a number of 0's and 1's.

(3) What's up with VBA's RND? Any sign of an impending upgrade?

Regards,
Dave B

"Mike Middleton" wrote in message
...
Allie -

See "Description of the effects of the improved statistical functions for
the Analysis ToolPak in Excel 2003 and in Excel 2004 for Mac," at

http://support.microsoft.com/default...b;en-us;829208

specifically, the "Random Number Generation" section.

- Mike
www.mikemiddleton.com

"Allie" wrote in message
...
Hi,

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able
to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an
extremely
unlikely circumstance with a true RN generator. I just wanted to raise
this
flag, as it could be affecting others without their knowledge.

Thanks,
Allie







  #11   Report Post  
Dana DeLouis
 
Posts: n/a
Default

Hi Alice. I believe this is a known problem. The first number in the list
follows a linear relationship with the seed.
With a 16 number output, the first number output runs from about 0 to 1 with
seeds 1 to about 10022. (It's a near perfect correlation. R^2 =
1.000000)With a seed of 10023, the first number drops back to near zero and
repeats the cycle.
So, when you seed with low numbers, there is little chance that another
number will be lower than the first one. As the seeds get larger, the first
number gets larger, and there are more chances that other numbers will be
lower than the first.

I was just curious, so I plotted the percentages that the first number was
the lowest out of 16. The plot starts out near 95% - 100% for a few hundred
numbers, and then exponentially decays to about 8% when reaching the largest
seed of 32767. Because of the "Bug", (err...I mean feature) it will never
get to the expected 6.25% (1/16).

If you would like to see a listing of the first number in the output, here
is a macro. There is no need to see all 32767, as the first few hundred
will show you the relationship.
Set a vba library reference to "atpvbaen.xls"
This takes a few minutes to run.

Here, the "C" is used as a seed number, and as a column pointer to store the
first output cell.

Sub Curious()
Dim C As Long
Const Random As String = "ATPVBAEN.XLA!Random"

[A:C].Clear

For C = 1 To 11000 '32767
[A1:A16].Clear
Run Random, Cells(1, 1), 1, 16, 1, C, 0, 1
Cells(C, 3) = Cells(1, 1)
Application.StatusBar = C
Next C
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"Allie" wrote in message
...
Hi,

I've been trying to generate random numbers using excel's random number
generator in the analysis toolpak. I'm using Uniform number generation
between 0 and 1, and I am using a random seed, as I would like to be able
to
re-generate the same numbers in the future.

Using seeds from 1 to 10, when i fill a range of 16 cells with random
numbers, the first cell filled is always the lowest. This is an extremely
unlikely circumstance with a true RN generator. I just wanted to raise
this
flag, as it could be affecting others without their knowledge.

Thanks,
Allie



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
random numbers, how can you utilize it without repeating them RS Excel Discussion (Misc queries) 1 September 9th 05 05:01 AM
How to alter data on HTML webpage into Excell cells as numbers? roameri New Users to Excel 6 July 31st 05 11:42 PM
Printing data validation scenarios SJC Excel Worksheet Functions 14 July 24th 05 12:43 AM
Sort pages? David Excel Discussion (Misc queries) 15 May 13th 05 11:33 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"