Asked by:
True Random Numbers May Repeat
General discussion

edited 16 Oct 2010  Professor Knuth replied. He correctly pointed out that all of Chapter 3, TAOCP Vol. 2 should be read. It was an error on my part to extract one paragraph from 3.1. Everything discussed in the following posts are covered in that Chapter. My apologies to Professor Knuth. Any person serious about random numbers should read TAOCP, Volume 2, Chapter 3 (in its entirety;). I see that the long awaited Volume 4A of TAOCP will be available in December of 2010.
Original Post follows:
I am posting this for the beginners that may come across other threads discussing the issue.
Random and Static Sets
As most of you hopefully know the tossing of a coin has an equal probability of being heads or tails and is a random process. If we toss a coin ONCE the score can be
Heads  1
Tails  0
or
Heads  0
Tails  1
If we stop there the score can never be
Heads  1
Tails  1
This demonstrates two important characteristics of understanding random.
1  A single random number is one that is drawn from a set of unique possible values(2 in the case of a coin), each of which is equally probable.
2  The only way a random number can be guaranteed to repeat is for the count of possible values + 1 to be drawn from a static set(3 in the case of a coin).
If we throw a coin twice probability says that the score can be:
Heads  1
Tails  1
It could also happen that heads or tails happens twice, but it is not 100% certain. However, when the coin is tossed the third time there is a 100% probability that there is a repeat.
Random and sets of values that are not static
For this example think of a standard deck of 52 playing cards.
Card games are an example of a random process performed against a set of values that change.Take a standard deck of 52 playing cards and shuffle them(randomize them).
Select one card at random from the shuffled deck and give it to your imaginary opponent. Lets say it is the 2 of clubs.
The next card to be selected at random will be yours. The probability that you will get the 2 of clubs is 0%.
The Random Class is a pseudorandom number generator(PRNG). The link provides some detail about the meaning of PRNG. One of the things it says is: "The chosen numbers are not completely random because a definite mathematical algorithm is used to select them, but they are sufficiently random for practical purposes ." This link http://www.random.org/randomness/ also has good information. Also, The Art of Computer Programming by Dr. Knuth should be mandatory reading for all programmers. Volume 2, Chapter 3 is titled Random Numbers. Most of the discussion deals with PRNG's.
A definition of the word random .
Two Dice
The throwing of two dice is one event that is the selection of two random numbers. The result does not violate this statement, a single random number is one that is drawn from a set of unique possible values, each of which is equally probable. The outcome of throwing two dice (Da and Db) are:
 Da1 Db1
 Da1 Db2
 Da1 Db3
 Da1 Db4
 Da1 Db5
 Da1 Db6
 Da2 Db1
 Da2 Db2
 Da2 Db3
 Da2 Db4
 Da2 Db5
 Da2 Db6
 Da3 Db1
 Da3 Db2
 Da3 Db3
 Da3 Db4
 Da3 Db5
 Da3 Db6
 Da4 Db1
 Da4 Db2
 Da4 Db3
 Da4 Db4
 Da4 Db5
 Da4 Db6
 Da5 Db1
 Da5 Db2
 Da5 Db3
 Da5 Db4
 Da5 Db5
 Da5 Db6
 Da6 Db1
 Da6 Db2
 Da6 Db3
 Da6 Db4
 Da6 Db5
 Da6 Db6
There are 36 possible outcomes, and each is equally probable(1 in 36). If you take the two random numbers generated by the throw of two dice and perform some mathematical function using those two numbers, the result is not random, it is a mathematical result.
The following is the result of throwing two dice and adding the resulting values. As can be seen the result of this mathematical operation is not random.
Sum 2 Probability 2.793 %
Sum 3 Probability 5.597 %
Sum 4 Probability 8.320 %
Sum 5 Probability 11.090 %
Sum 6 Probability 13.873 %
Sum 7 Probability 16.655 %
Sum 8 Probability 13.840 %
Sum 9 Probability 11.171 %
Sum 10 Probability 8.289 %
Sum 11 Probability 5.602 %
Sum 12 Probability 2.772 %The code for both dice tables is in another post, and builds upon the first piece of code.
Added a PRNG with a uniform distribution using the Mersenne Twister algorithm to the post with code. The code was written by Paul Vick of Microsoft . See the post for a link to his blog.
The code is a great example of what goes into writing a PRNG.
I will make changes and give credit (as needed) to this post so we never have to have this discussion again.
Other contributors: Riced, Solitaire, Renee Culver
Subnet Calculator / Planner Serial Port Edited by dbasnett Saturday, October 16, 2010 9:15 PM
Thursday, August 12, 2010 5:24 PM
All replies

1  A single random number is one that is drawn from a set of possible values(2 in the case of a coin), each of which is equally probable .
Equal probability is not a requirement. Consider throwing two dice where the number drawn is the sum of the uppermost faces. Probabilty of 2 is 1/36; probability of 7 is 6/36. Yet the number drawn is a random one between 2 and 12.
If you perform steps 24, 52 times(53 total cards selected) there is a 100% probability that you will select the card at step 1 again.
Not so. Consider drawing 2 of clubs on first draw. Then every subsequent draw is not the 2 of clubs. There will be a repetition (that's certain) but there is no reason that the first card drawn will be drawn again.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Thursday, August 12, 2010 7:35 PM 
Your point about number 1 is incorrect in the case of a single random draw from a static set. Throwing two dice is akin to multiple draws.
I agree with point 2 and will correct. Thanks!
Subnet Calculator / Planner Serial Port Edited by dbasnett Thursday, August 12, 2010 8:23 PM
Thursday, August 12, 2010 8:02 PM 
'create a new form application
'Add 4 Buttons
'Add 1 RichtextBox
'Add 1 NumericUpDown
'Copy / Paste this code
'
Public Class Form1
Private Sub Form1_Shown(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Shown
NumericUpDown1.Minimum = 1
NumericUpDown1.Maximum = 20
NumericUpDown1.Value = 2
End Sub
Private PRNG As New Random 'note class level declaration
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
'simulate tossing coin NumericUpDown1.Value times
'random process  set of values static
Dim heads As Integer = 0
Dim tails As Integer = 0
For ct As Integer = 1 To CInt(NumericUpDown1.Value) 'toss the coin NumericUpDown1.Value times
Dim toss As Integer = PRNG.Next(1, 3) '1 = heads, 2 = tails
Select Case toss
Case 1 'heads
heads += 1
Case 2 'tails
tails += 1
End Select
Next
RichTextBox1.Clear()
RichTextBox1.AppendText(String.Format("The coin was tossed {0} times.{1}", _
NumericUpDown1.Value.ToString, _
Environment.NewLine))
RichTextBox1.AppendText(String.Format("There were {0} heads.{1}", _
heads.ToString, _
Environment.NewLine))
RichTextBox1.AppendText(String.Format("There were {0} tails.{1}", _
tails.ToString, _
Environment.NewLine))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
'simulate a lotto game
'random process  set of values change
'in this game there a 50 numbered balls (150)
'6 are drawn randomly
'step 1  create 50 balls
Dim balls As New List(Of Integer) 'hopper
For ball As Integer = 1 To 50
balls.Add(ball) 'add to hopper
Next
'step 2  select 6 numbers at random
Dim winner As New List(Of Integer)
'List(Of ...) are zero based
For ct As Integer = 1 To 6
Dim selector As Integer = PRNG.Next(0, balls.Count) 'pick a random ball from hopper
winner.Add(balls(selector)) 'add ball to winning selection
balls.RemoveAt(selector) 'remove ball from hopper
Next
'show winning lotto number
RichTextBox1.Clear()
For x As Integer = 0 To winner.Count  1
RichTextBox1.AppendText(winner(x).ToString & Environment.NewLine)
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button3.Click
'Dice
'the combination of two random events
RichTextBox1.Clear()
For Da As Integer = 1 To 6
For Db As Integer = 1 To 6
RichTextBox1.AppendText(String.Format("Da{0} Db{1}{2}", _
Da.ToString, _
Db.ToString, _
Environment.NewLine))
Next
Next
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'The key is the addition of two die, the value is times thrown
Dim dice As New SortedDictionary(Of Integer, Integer)
Const throws As Integer = 1000000 'number of times to throw dice
RichTextBox1.Clear()
For x As Integer = 1 To throws
Dim da As Integer = PRNG.Next(1, 7)
Dim db As Integer = da + PRNG.Next(1, 7)
If dice.ContainsKey(db) Then
dice(db) += 1
Else
dice.Add(db, 1)
End If
Next
For Each kvp As KeyValuePair(Of Integer, Integer) In dice
RichTextBox1.AppendText(String.Format("Sum {0} Probability {1}{2}", _
kvp.Key.ToString.PadRight(2, " "c), _
(kvp.Value / throws).ToString("p3"), _
Environment.NewLine))
Next
End Sub
End Class
'''
''' written by: Paul Vick of Microsoft
'''
''' http://panopticoncentral.net/archive/2006/09/22/16342.aspx
'''
''' A random number generator with a uniform distribution using the Mersenne
''' Twister algorithm.
'''
Public Class MersenneTwister
Private Const N As Integer = 624
Private Const M As Integer = 397
Private Const MATRIX_A As UInteger = &H9908B0DFUI
Private Const UPPER_MASK As UInteger = &H80000000UI
Private Const LOWER_MASK As UInteger = &H7FFFFFFFUI
Private mt(N  1) As UInteger
Private mti As Integer = N + 1
'''
''' Create a new Mersenne Twister random number generator.
'''
Public Sub New()
Me.New(CUInt(Date.Now.Millisecond))
End Sub
'''
''' Create a new Mersenne Twister random number generator with a
''' particular seed.
'''
''' The seed for the generator.
Public Sub New(ByVal seed As UInteger)
mt(0) = seed
For mti = 1 To N  1
mt(mti) = CUInt((1812433253UL * (mt(mti  1) Xor (mt(mti  1) >> 30)) + CUInt(mti)) And &HFFFFFFFFUL)
Next
End Sub
'''
''' Create a new Mersenne Twister random number generator with a
''' particular initial key.
'''
''' The initial key.
Public Sub New(ByVal initialKey() As UInteger)
Me.New(19650218UI)
Dim i, j, k As Integer
i = 1 : j = 0
k = CInt(IIf(N > initialKey.Length, N, initialKey.Length))
For k = k To 1 Step 1
mt(i) = CUInt(((mt(i) Xor ((mt(i  1) Xor (mt(i  1) >> 30)) * 1664525UL)) + initialKey(j) + CUInt(j)) And &HFFFFFFFFUI)
i += 1 : j += 1
If i >= N Then mt(0) = mt(N  1) : i = 1
If j >= initialKey.Length Then j = 0
Next
For k = N  1 To 1 Step 1
mt(i) = CUInt(((mt(i) Xor ((mt(i  1) Xor (mt(i  1) >> 30)) * 1566083941UL))  CUInt(i)) And &HFFFFFFFFUI)
i += 1
If i >= N Then mt(0) = mt(N  1) : i = 1
Next
mt(0) = &H80000000UI
End Sub
''' comment by Dewayne Basnett  Except for the Double variety this code differs from the Random Class
''' in that both bounds are inclusive.
'''
'''
''' Generates a random number between 0 and System.UInt32.MaxValue.
'''
Public Function GenerateUInt32() As UInteger
Dim y As UInteger
Static mag01() As UInteger = {&H0UI, MATRIX_A}
If mti >= N Then
Dim kk As Integer
Debug.Assert(mti <> N + 1, "Failed initialization")
For kk = 0 To N  M  1
y = (mt(kk) And UPPER_MASK) Or (mt(kk + 1) And LOWER_MASK)
mt(kk) = mt(kk + M) Xor (y >> 1) Xor mag01(CInt(y And &H1))
Next
For kk = kk To N  2
y = (mt(kk) And UPPER_MASK) Or (mt(kk + 1) And LOWER_MASK)
mt(kk) = mt(kk + (M  N)) Xor (y >> 1) Xor mag01(CInt(y And &H1))
Next
y = (mt(N  1) And UPPER_MASK) Or (mt(0) And LOWER_MASK)
mt(N  1) = mt(M  1) Xor (y >> 1) Xor mag01(CInt(y And &H1))
mti = 0
End If
y = mt(mti)
mti += 1
' Tempering
y = y Xor (y >> 11)
y = y Xor ((y << 7) And &H9D2C5680UI)
y = y Xor ((y << 15) And &HEFC60000UI)
y = y Xor (y >> 18)
Return y
End Function
'''
''' Generates a random integer between 0 and System.Int32.MaxValue.
'''
Public Function GenerateInt32() As Integer
Return CInt(GenerateUInt32() >> 1)
End Function
'''
''' Generates a random integer between 0 and maxValue.
'''
''' The maximum value. Must be greater than zero.
Public Function GenerateInt32(ByVal maxValue As Integer) As Integer
Return GenerateInt32(0, maxValue)
End Function
'''
''' Generates a random integer between minValue and maxValue.
'''
''' The lower bound.
''' The upper bound.
Public Function GenerateInt32(ByVal minValue As Integer, ByVal maxValue As Integer) As Integer
Return CInt(Math.Floor((maxValue  minValue + 1) * GenerateDouble() + minValue))
End Function
'''
''' Generates a random floating point number between 0 and 1.
'''
Public Function GenerateDouble() As Double
Return GenerateUInt32() * (1.0 / 4294967295.0)
End Function
End Class
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 8:04 PM 
Have to disagree about 1. Here's a variation. I have a bag with 36 balls; one is numbered 2, two are numbered 3, three are numbered 4, four are numbered 5, five are numbered 6, six are numbered 7, five are numbered 8, four are numbered 9, three are numbered 10, two are numbered 11, one is numbered 12. I shake the bag and withdraw a ball. What is the probability of it being 2? What is the probability of it being 7?
This is exactly analogous to throwing two dice. It is one event where the probabilty of obtaining a particular result is not uniformly distributed. However the process is random. Hence, I would argue, the resulting numbers are random.The confusion arises (I think) because of two facts. First, in books of statistical tables there is usually a table of random digits that are uniformly distributed. Secondly, many programming languages provide a random number generator that produces a uniform distribution. Commonly done using a linear congruential generator to provide a sequence of values (x) such that 0<=x<1. This leads people to equate 'random number' with uniform distribution. But that is not the case, what is required is that the underlying distribution be known exactly or approximately too a high degree.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Thursday, August 12, 2010 9:16 PM 
"1  A single random number is one that is drawn from a set of possible values(2 in the case of a coin), each of which is equally probable .
Equal probability is not a requirement."Then the sample is not a random sample. With real random numbers, which is what I've been talking about equiprobability is a requirement. The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are.
Cards are not random (period). Cards may be drawn at random but they lack the properties of randomness.
Renee
Thursday, August 12, 2010 10:38 PM 
What is your defintion of random?
Renee
Thursday, August 12, 2010 10:42 PM 
" certainty that you have drawn at least one duplicate card every time the test is"
Randomness is done on statistical probability not on absolute certainty. The "absolute certainty" is another way of specifying the number of cards in the deck.
Renee
Thursday, August 12, 2010 10:50 PM 
I need to alter the card statement above. Cards which are not replaced are not random distributions. ReneeThursday, August 12, 2010 10:56 PM

Have to disagree about 1. Here's a variation. I have a bag with 36 balls; one is numbered 2, two are numbered 3, three are numbered 4, four are numbered 5, five are numbered 6, six are numbered 7, five are numbered 8, four are numbered 9, three are numbered 10, two are numbered 11, one is numbered 12. I shake the bag and withdraw a ball. What is the probability of it being 2? What is the probability of it being 7?
This is exactly analogous to throwing two dice. It is one event where the probabilty of obtaining a particular result is not uniformly distributed. However the process is random. Hence, I would argue, the resulting numbers are random.The confusion arises (I think) because of two facts. First, in books of statistical tables there is usually a table of random digits that are uniformly distributed. Secondly, many programming languages provide a random number generator that produces a uniform distribution. Commonly done using a linear congruential generator to provide a sequence of values (x) such that 0<=x<1. This leads people to equate 'random number' with uniform distribution. But that is not the case, what is required is that the underlying distribution be known exactly or approximately too a high degree.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.
The throw of each die will represent a random event for that die with a 1 in 6 chance of it being any one of the numbers on that die. I did not discuss combining random processes.Sequences of random numbers must be statistically independent of each other. If you roll a die 100 times and it comes up 3 every time, the odds for 3 being thrown next are still 1 in 6. The odds that it will be 1,2,4,5, or 6 are still 5 in 6.
In the case of combining random events I agree that the resulting number (i.e. two die) will not have a uniform distribution across the set of possible outcomes. I shoot craps so I am intimately familiar with your point (buck yo!).
Subnet Calculator / Planner Serial Port Edited by dbasnett Thursday, August 12, 2010 11:37 PM
Thursday, August 12, 2010 11:05 PM 
"1  A single random number is one that is drawn from a set of possible values(2 in the case of a coin), each of which is equally probable .
Equal probability is not a requirement."Then the sample is not a random sample. Which real random numbers, which is what I've been talking about equiprobability is a requirement. The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are.
Cards are not random (period). Cards may be drawn at random but they lack the properties of randomness.
Renee
Try reading ALL of the words for a change.
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:07 PM 
"If you roll a die 100 times and it comes up 3 every time, the odds for 3 being thrown again are still 1 in 6. The odds that it will be 1,2,4,5, or 6 are still 5 in 6."
Correct and elementary.
Renee
Thursday, August 12, 2010 11:09 PM 
" certainty that you have drawn at least one duplicate card every time the test is"
Randomness is done on statistical probability not on absolute certainty. The "absolute certainty" is another way of specifying the number of cards in the deck.
Renee
I removed that section until I can think of a better way of expressing it.OT  When you find a question that is not to your liking, don't waste your time. My start was not as an applications programmer. If what you have said is true, while you were playing around with mini computers at DEC I was a systems programmer on a large mainframe with multiple CPU's. You are the only one impressed with you.
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:14 PM 
Well, your not impressed because you don't know much about DEC although Windows is directly descended from DEC machines which were 64bit machines. Im impessed because I know about them. You don't know about them.
"You are the only one impressed with you."
You do have serious boundary problems. Now you are speaking for everyone.
Renee
Thursday, August 12, 2010 11:21 PM 
What is your defintion of random?
Renee
Added definition link.
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:22 PM 
Well, your not impressed because you don't know much about DEC although Windows is directly descended from DEC machines which were 64bit machines. Im impessed because I know about them. You don't know about them.
Renee
Are you sure? Did we have Vax 11/780's at NASA(Castor / Pollux)? You keep making the same fundamental mistake Renee, you never know who you are talking to. You may have worked with them...
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:27 PM 
1  A single random number is one that is drawn from a set of possible values(2 in the case of a coin), each of which is equally probable .
Equal probability is not a requirement. Consider throwing two dice where the number drawn is the sum of the uppermost faces. Probabilty of 2 is 1/36; probability of 7 is 6/36. Yet the number drawn is a random one between 2 and 12.But in your series of result from 2 dice, one sixth of the number will be 7
so if you accept this as a series of random number, a series with one fifth of the number have also to be accepted as a series of random number
and so should you with a series with one forth, and one third and half
and so should you with a long series of 7 with only one value different
and since a series can be of any length, even infinite,
so since the ( Limit when N> infinty) will tells you that such series if it contains only the value 7 is a random series ( which is false )
unless there is a magical maximun number of 7 that can be accepted
Thursday, August 12, 2010 11:33 PM 
"You may have worked with them..." I wrote major pieces of VMS, I did not just work with them. 780s...we went much, much further. A 780 was a 32 bit machine while an Alpha was a 64 bit machine. I've been at any number of Nasa sites like Goddard, Langley and Pax River. Quite frankly they didn't have the most advanced systems or programmers. ReneeThursday, August 12, 2010 11:37 PM

"If you roll a die 100 times and it comes up 3 every time, the odds for 3 being thrown again are still 1 in 6. The odds that it will be 1,2,4,5, or 6 are still 5 in 6."
Correct and elementary.
Renee
Read all the words, as in the first sentence of the first post.
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:38 PM 
"You may have worked with them..." I wrote major pieces of VMS, I did not just work with them. 780s...we went much, much further. A 780 was a 32 bit machine while an Alpha was a 64 bit machine. I've been at any number of Nasa sites like Goddard, Langley and Pax River. Quite frankly they didn't have the most advanced systems or programmers. Renee
So you say. Tell me Renee, what part did DEC play in putting a man on the moon? Nothing impressive about that?
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:45 PM 
"without pattern: done, chosen, or occurring without an identifiable pattern, plan, system, or connection"random checks"2.lacking regularity: with a pattern or in sizes that are not uniform or regular"a wall constructed of random stones"3.statistics equally likely: relating or belonging to a set in which all the members have the same probability of occurrence"a random sampling"4.statistics having definite probability: relating to or involving variables that have undetermined value but definite probability"I would have expected a google definition from you. Yes, Three and four are part of the properties of a random distribution. The numbers do have an undetermined or random instantaneous value and a longterm frequency or probability.ReneeThursday, August 12, 2010 11:48 PM

I corrected 1 to read
1  A single random number is one that is drawn from a set of unique possible values(2 in the case of a coin), each of which is equally probable.
Subnet Calculator / Planner Serial PortThursday, August 12, 2010 11:49 PM 
What is going on with the 2 dice, is you have picked 2 random number from 1 to 6 and have add then together. This is a process so the series is not a series of random number
Thursday, August 12, 2010 11:54 PM 
I don't know what DEC had to do with putting a man on the moon. But I must say, Nasa had some good contractors. Nasa did not do that much themselves. Actually, like everything else they are on a Bell curve, BUT that's offtopic for this thread. Topics are boundary laden you know.
Renee
Thursday, August 12, 2010 11:55 PM 
"What is going on with the 2 dice, is you have picked 2 random number from 1 to 6 and have add then together. This is a process so the series is not a series of random number"
The actual range for single digit is between 2 and 12 with the modal number being 7. There will definitely be a distribution centered around 7.
Renee
Friday, August 13, 2010 12:01 AM 
"without pattern: done, chosen, or occurring without an identifiable pattern, plan, system, or connection
"random checks"2.lacking regularity: with a pattern or in sizes that are not uniform or regular"a wall constructed of random stones"3.statistics equally likely: relating or belonging to a set in which all the members have the same probability of occurrence"a random sampling"4.statistics having definite probability: relating to or involving variables that have undetermined value but definite probability"I would have expected a google definition from you. Yes, Three and four are part of the properties of a random distribution. The numbers do have an undetermined or random instantaneous value and a longterm frequency or probability.Renee
I can't tell you how delighted I am to have exceeded your expectations.
Subnet Calculator / Planner Serial PortFriday, August 13, 2010 12:01 AM 
The personal attacks have started so this is now another flame fest.
Renee: I have discussed the question of randomness before in a previous thread. I don't intend to repeat that discussion.
dbasnett: A promising discussion has now gone down the Swanee. A pity because it could have been informative.
To others: You may as well ignore this thread from now on.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 4:21 AM 
The throw of each die will represent a random event for that die with a 1 in 6 chance of it being any one of the numbers on that die. I did not discuss combining random processes.
1. The event of interest is the score obtained in throwing two dice  this is one event. No random processes are being combined since throwing two dice is one occurrence of a single process.
2. Does not address the alternative of drawing one ball from the bag of 36. That clearly is one event.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 4:37 AM 
"Renee: I have discussed the question of randomness before in a previous thread. I don't intend to repeat that discussion."
That's good because you have not begun to participate in a full discussion of Random. Your choosing not to discuss it further is indeed your decision and choice.
Renee
Friday, August 13, 2010 5:50 AM 
That's good because you have not begun to participate in a full discussion of Random.
I refer you to the previous thread: http://social.msdn.microsoft.com/Forums/enUS/Vsexpressvb/thread/877a76b19501484eb0e5e41ae7d0ef1d/#0b8a2fe857974709a943b7d68c4f5504
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 6:05 AM 
I don't follow the argument. If two dice are thrown a large number of times and the resulting score is recorded this gives you a sequence of numbers in the range 2 to 12. The distribution of that sequence can be recorded (i.e. how many 2s, how many 3s,... how many 12s). If the dice are fair then this will show that the number 2 occurs with frequency approximately 1/36 of total frequency; 7 will occur with probability approximately 1/6.
Suppose you carry out the experiment and produce such a sequence, what is the probability that the next roll of the dice will produce a score of 7? Can you tell me with certainty what the next score will be? If you can the sequence is not random.
I would not, and never have, claimed that the sequences you describe are random. Nor do I think you can say I must do so, since all I mean is that you cannot predict with certainty what the next number will be. Given other knowledge, such as the probability distribution, you can make a probabilistic prediction.
Suppose you throw two dice a large number of times and find that 7 occurs 50% of the time and the other scores all occur 5% of the time. Then you could reasonably conclude that the dice were loaded. You still could not predict with certainty what the next score will be. You could predict that there is a 50% chance it's 7 but there is also a 50% it's not. So even loaded dice can produce a random sequence of numbers. They are just not the sequence you might expect.
PS You almost certainly would not want to use such a sequence to e.g. simulate a card game. And you definitely don't want to use it to simulate a process that requires uniformly distributed values. But that does not make it any the less random.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute. Edited by Riced Friday, August 13, 2010 6:43 AM Added PS
Friday, August 13, 2010 6:38 AM 
Friday, August 13, 2010 11:56 AM

I added the code for the dice to the existing post with code. I will never use code tags again!!
Subnet Calculator / Planner Serial Port RandomFriday, August 13, 2010 3:37 PM 
The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are
I have two distributions: first is the value obtained by throwing a 6 sided die, second is a (approximately) Normal distribution of integers with mean=100 sd=20.
The die is thrown and a number of times. At the same time a number is drawn from the Normal distribution.
Which sequence is more predictable? For which sequence is the probability of obtaining 6 (on any given throw) the higher?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 4:24 PM 
The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are
I have two distributions: first is the value obtained by throwing a 6 sided die, second is a (approximately) Normal distribution of integers with mean=100 sd=20.
The die is thrown and a number of times. At the same time a number is drawn from the Normal distribution.
Which sequence is more predictable? For which sequence is the probability of obtaining 6 (on any given throw) the higher?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.
I am not certain what you are driving at. A die represents 6 unique numbers. If I throw the die the number selected is random because it had an equal probability of being selected.
Subnet Calculator / Planner Serial Port RandomFriday, August 13, 2010 4:37 PM 
Friday, August 13, 2010 4:50 PM

Some basic statistics which might explain why I don't consider uniformity as necessary for randomness.
1 Suppose we are interested in finding out what is going to happen when an act is performed and the outcome is uncertain. We can perform the act a number of times under similar conditions and record the outcomes. Such a process is a random (or stochastic, or chance) process. Examples of such acts are tossing a single coin, tossing three coins, throwing a die, throwing two dice, selecting a sample of items produced in some manufacturing process, etc. If the act is repeated then the outcomes in all cases is random.
2 Each performance of the act is a trial, and all trials under the same conditions are an experiment (which can be one or more trials). So an experiment could be a single throw of a die or 100 throws of a die.
3 The result of a trial is called as outcome, or sample point, or an (elementary) event.
4 The collection or set of all possible outcomes (sample points, events) of an experiment constitutes a sample space.
Now consider the following acts and their sample spaces:
(a) Tossing a single coin and the outcome is recorded as H or T. The sample space is the set S = {H, T}
(b) A single die is thrown. The sample space is the set S = {1, 2, 3, 4, 5, 6}
(c) Two coins are tossed simultaneously and the outcomes, H or T, are recorded. The sample space is the set S = {(H,H), (H,T), (T,H), (T,T)}
(d) Two coins are tossed simultaneously and the number of tails is recorded. The sample space is the set S = {0, 1, 2}
(e) Two dice are thrown and the sum of the uppermost faces is recorded. The sample space is the set S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
Notice that the sample space depends on the act and how we wish to record the outcomes e.g. compare (c) and (d).
Also notice another property of the sample space. In some cases the sample points in the sample space are equally likely (e.g. a or b); in other cases they are not (e.g. d or e).
Now consider the following situation: a shipment of 100 TV screens is received each of which is either defective (Bad) or nondefective (Good). If we draw 4 screens from the shipment what constitutes the sample space? Given 4 screens the sample space is the set:
S = {(G,G,G,G), (G,G,G,B), (G,G,B,G), (G,G,B,B), (G,B,G,G), (G,B,G,B), (G,B,B,G), (G,B,B,B), (B,G,G,G), (B,G,G,B), (B,G,B,G), (B,G,B,B), (B,B,G,G), (B,B,G,B), (B,B,B,G), (B,B,B,B)}
Are these equally likely outcomes? Suppose the defect rate is 1%, is it likely that all 4 screens will be bad or all 4 good, i.e. does getting (B,B,B,B) have the same probability as getting (G,G,G,G)?
So what can we draw from this?
Firstly, the sample space depends on what we want to measure as the outcome of a trial, i.e. it depends on how we define the events.
Secondly, each point in the sample space (or each event) has a probability of occurring. If there was only one point then the event is bound to occur and it's probability would be 1  so not very interesting. Where more than one event can occur, the probability of a particular event is given by (the number of possible ways the event can occur)/(the total number of possible outcomes). E.g. in (c) there are four possible events (assuming we can distinguish (H,T) from (T,H) each having probability 1/4. In (d) there are three possible events, but the event 1 tail can happen in two possible ways. So the total number of possible outcomes is four, and 1 tail can occur in two possible ways so its probability is 2/4 (or 1/2).
Thirdly, the probabilities of the events are not necessarily equal.
Finally, to insist on equal probabilities for all events in the sample space rules out many random processes and hence a huge host of statistics.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 6:06 PM 
"Which sequence is more predictable? For which sequence is the probability of obtaining 6 (on any given throw) the higher?"
Are you equating randoness with the ability to predict it with statistical occurences at greater than chance rates? I hope you are going into more detail on what randonmess is than just an inability to predict the number.
Renee
Friday, August 13, 2010 6:29 PM 
Let me rephrase it.
I have two probability distributions. One is uniformly distributed from 1 to 6; the other Normally distributed mean=100, sd=20.
I draw one number from each distribution. Which distribution is most likely to produce 6?
The answer is the uniform one, since among other things the Normal distribution has a wider range (rougly 99% of values lie in range 40 to 160, so the chances of 6 are remote).
This was a response to the statement:
The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are.
This claims that you get greater predictability the less equiprobable the distribution, however I have provide an example where that is not the case. In fact knowing that a distribution is equiprobable does not tell you how predictable it is. Consider a uniform distribution with range 1 to 10^25, against a Normal distribution with mean=100 and sd=5.
the number selected is random because it had an equal probability
I would say the number is random because you cannot predict it with certainty, it just happens that when throwing a die we believe each number has the same probability of turning up. You can, as with any distribution, make a prediction based on probability e.g. the probability of an odd number is 1/2. The only certain prediction is that the number is between 1 and 6.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 7:00 PM 
"Which sequence is more predictable? For which sequence is the probability of obtaining 6 (on any given throw) the higher?"
Are you equating randoness with the ability to predict it with statistical occurences at greater than chance rates ? I hope you are going into more detail on what randonmess is than just an inability to predict the number.
This is not answer to the questions quoted.
I have already gone into randomness in some detail in another thread as you know. You might also consider my post on basic statistics in this thread.
I don't understand what the underlined phrase means, so I cannot answer the question.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Friday, August 13, 2010 7:08 PM 
(e) Two dice are thrown and the sum of the uppermost faces is recorded. The sample space is the set S = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
I think I addressed this. The result is not random but the method used to derive the result was. Taking two random results and contriving some "fact" may result in an outcome that is not random.
"Now consider the following situation: a shipment of 100 TV screens is received each of which is either defective (Bad) or nondefective (Good). If we draw 4 screens from the shipment what constitutes the sample space? Given 4 screens the sample space is the set:
S = {(G,G,G,G), (G,G,G,B), (G,G,B,G), (G,G,B,B), (G,B,G,G), (G,B,G,B), (G,B,B,G), (G,B,B,B), (B,G,G,G), (B,G,G,B), (B,G,B,G), (B,G,B,B), (B,B,G,G), (B,B,G,B), (B,B,B,G), (B,B,B,B)}
Are these equally likely outcomes? Suppose the defect rate is 1%, is it likely that all 4 screens will be bad or all 4 good, i.e. does getting (B,B,B,B) have the same probability as getting (G,G,G,G)?"The initial set is 100 TV's, T1, T2, T3,... T100. If each TV has an equal probability of being selected then the sample itself is random and what the sample looks like from the perspective of defective rate has no bearing on the randomness.
Subnet Calculator / Planner Serial Port RandomFriday, August 13, 2010 11:31 PM 
Very simple. This is the original statement:
The less equiprobable the resulting numbers, the more predictable the numbers are and the less randow they are
All the numbers for a die are equiprobable (i.e. 1/6), the numbers from a Normal distribution are notequiprobable. In the example (mean=100, sd=20) then approximately 99% will lie in range 40 to 160. So the probability of getting say 12 is negligible, while probability of getting something close to 100 is reasonably high. So the Normal values are less equiprobable than those of a die. Yet the predictability of the Normal sequence is much less than that of the die sequence contrary to what is claimed.
If you don't believe that try writing a program to simulate a sequence of throws, and to simulate of values from a Normal distribution (say ~N(100,20)). Then see which is the more predictable. Use the program to construct (relative) frequency distributions and compare them. Get the program to print pairs (one from each distribution) and predict the next pair. Which of your predictions is more accurate.
Now which of the two sequences would you say shows the greater randomness?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Saturday, August 14, 2010 2:19 PM 
I have posted the code for a dice game that shows that the sum of the numbers is not random. Why don't you post code for your normal distribution.
Subnet Calculator / Planner Serial Port RandomSaturday, August 14, 2010 3:16 PM 
The output does not show the sequence so it's not clear whether or not is random. What is clear is that the distribution is not uniform. And that is exactly what I would expect with probabilities: 2.8, 5.6, 8.3, 11.1, 13.9, 16.7, 13.9, 11.1, 8.3, 5.6, 2.8. Which are pretty much what you got.
You could only claim the output was nonrandom if you subjected the sequence of outputs to various statistical tests and it failed those tests. However, what would constitute an acceptable set of tests would have to be agreed before performing the experiment. That's because testing for randomness is not a cut and dried process.
As for a program to generate Normal sequences  I've not written one for years (in C on a DOS box IIRC) but might do something in next few days.:)
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Saturday, August 14, 2010 4:11 PM 
It just so happens that Knuth's Book has a look inside. If you click the Look Inside link and scroll through the first couple of pages you will find what I believe a "sequence of independent random numbers" is.
Subnet Calculator / Planner Serial Port RandomSaturday, August 14, 2010 5:03 PM 
Added a PRNG with a uniform distribution using the Mersenne Twister algorithm to the post with code. The code was written by Paul Vick of Microsoft . See the post for a link to his blog.
The code is a great example of what goes into writing a PRNG.
Subnet Calculator / Planner Serial Port RandomSaturday, August 14, 2010 6:10 PM 
Quote from Knuth:
"Rather, we speak of a sequence of independent random numbers with a specified distribution, and this means loosely that each number was obtained merely by chance, having nothing to do with other numbers of the sequence, and that each number has a specified probability of falling in any given range of values."
This does not say the probabilities have to be equal. In the two dice experiment the number 2 has probability 1/36, the number 7 has probability 1/6. Both have specified probabilities, so that fits Knuth's definition. Further the number obtained on any trial is independent of previous trials, and it is obtained by chance. The distribution is specified by giving the probabilities of each number (from 2 to 12). All in all, fits Knuth to a tee.
Two further references:
http://www.nrbook.com/devroye/ Nonuniform Random Variates Generation
http://www.fizyka.umk.pl/nrbook/bookcpdf.html Numerical Recipes in C, see Chapter 7.And a quote from the latter:
"Uniform deviates are just random numbers that lie within a specified range
(typically 0 to 1), with any one number in the range just as likely as any other. They
are, in other words, what you probably think “random numbers” are." And by implication that's not exactly what they, there's a bit more too them.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Saturday, August 14, 2010 8:32 PM 
Is "This does not say the probabilities have to be equal." what we are disagreeing about?
What did Dr. Knuth say in the next paragraph?
From NIST :"A random bit sequence could be interpreted as the result of the flips of an unbiased “fair” coin with sides
that are labeled “0” and “1,” with each flip having a probability of exactly ½ of producing a “0” or “1.”
Furthermore, the flips are independent of each other: the result of any previous coin flip does not affect
future coin flips. The unbiased “fair” coin is thus the perfect random bit stream generator, since the “0”
and “1” values will be randomly distributed (and [0,1] uniformly distributed ). All elements of the
sequence are generated independently of each other, and the value of the next element in the sequence
cannot be predicted, regardless of how many elements have already been produced."My interpretation of "uniformly distributed" is equal probabilities.
Subnet Calculator / Planner Serial Port Random Edited by dbasnett Sunday, August 15, 2010 1:23 PM
Saturday, August 14, 2010 9:22 PM 
dbasnett, RE: your initial post 
Grammar clarification:
Die is singular.
Dice is plural.
You had it the other way around.
SolitaireSaturday, August 14, 2010 9:58 PM 
dbasnett, RE: your initial post 
Grammar clarification:
Die is singular.
Dice is plural.
You had it the other way around.
Solitaire
I do know that. I was trying to make a distinction that need not have been made. I went back a corrected the post, and it reads better IMHO. Thanks for your input!
Subnet Calculator / Planner Serial Port RandomSaturday, August 14, 2010 10:56 PM 
Uniformly distributed does mean equal probabilities, never said it does not.
But random does not mean uniformly distributed, which is what both you and Renee claim.
Knuth's next paragraph is: "A uniform distribution on a finite set of numbers is one in which each possible number is equally probable. A distribution is generally understood to be uniform unless some other distribution is specifically mentioned."
This simply defines a uniform distribution and says when no distribution is mentioned it is generally taken to be uniform. Taking the two paragraphs together still does not lead to random means uniformly distributed. The first paragraph gives a general definition of random numbers; the second specifies a particular distribution.
From NIST document: "The National Institute of Standards and Technology (NIST) believes that these procedures are useful in detecting deviations of a binary sequence from randomness." (Italics in original)
Both quotes from the NIST document, show that it is considering a specific case where the distribution is uniform viz. testing the binary sequence, i.e. the bits, produced by a PRNG (equivalent to tossing a coin). That is pretty common in testing computer generated sequences since most generators produce uniform distributions by design. Again,
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Sunday, August 15, 2010 11:55 AM 
Here's some code that produces Normal deviates  well it probably does, not been subject to statistical tests but looks ok.
Create a Form and add:
Textbox: txtResults, set Multiline = True. For ease of reading set Font to Courier New, 10pt
NumericUpDown: nudTrials. The number of trials in a sample.
Button: btnGetNormal
Button: btnGetApprox
Textbox: txtNextDeviate
Button: btnNextDeviate
Add class to projects: NormalDistribution.
Paste following code into form and class files.
The NormalDistribution class provides four functions to get a Normally distributed deviate.
Deviate(), ApproxDeviate(): get a value distributed with given mean and standard deviation. Parameters are optional and default tp mean=100, sd=20.
StandardDeviate(), ApproxStdDeviate: get a value distributed N(0,1)
The differences in each pair are on how the deviate is generated from the built in uniform generator (i.e. Random).
The code in Form1 provides a crude test harness for the NormalDistribution class.
Note that(a) This has not been extensively tested. It will fail if the generated value is negative or greater than 240, the odds are miniscule but, theoretically, it could happen. (b) It relies on defaults for mean and sd. If you use different mean or sd you need to change the GetFrequenctDistribution() function to make sure your array will hold the possible range of values.
Does NormalDistribution produce a set of random variables that are Normally distributed? Possibly, it depends on your criteria for determining acceptance. That requires subjecting it to a battery of statistical test. However, both approaches use algorithms that tend to produce Normal distributions. Also when running it it looks like it does i.e. approx 68% of values in range meansd to mean+sd; approximately 99% in range mean3sd to mean+3sd.
The Next Deviate button can be used to test your predictions. Write down your prediction, press the button and compare with result. Do this many times and see how often you are right. Compare that with predicting e.g. coin tosses or die throws. Which is most predicatble (i.e. which experiment gives you highest proportion of correct answers)? Given a large sequence of deviates, can you come up with a formula that gives you better than 50% chance of being correct?
'
' Code for Form1
'
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
nudTrials.Minimum = 10
nudTrials.Maximum = 200000
nudTrials.Increment = 5
nudTrials.Value = 10000
End Sub
Private Sub btnGetNormal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetNormal.Click
Dim sample() As Integer = GetFrequencyDistribution()
ShowResults(sample, 20)
End Sub
Private Sub btnGetApprox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetApprox.Click
Dim sample() As Integer = GetApproxFrequencyDistribution()
ShowResults(sample, 20)
End Sub
Private Function GetFrequencyDistribution() As Integer()
Dim norm As NormalDistribution = New NormalDistribution()
Dim freqDist(10) As Integer
Dim sampleSize As Integer = CInt(nudTrials.Value)
Dim classWidth As Integer = 20
For i As Integer = 1 To sampleSize
Dim x As Integer = CInt(norm.Deviate())
freqDist(x \ classWidth) += 1
Next
Return freqDist
End Function
Private Function GetApproxFrequencyDistribution() As Integer()
Dim norm As NormalDistribution = New NormalDistribution()
Dim freqDist(10) As Integer
Dim sampleSize As Integer = CInt(nudTrials.Value)
Dim classWidth As Integer = 20
For i As Integer = 1 To sampleSize
Dim x As Integer = CInt(norm.ApproxDeviate())
freqDist(x \ classWidth) += 1
Next
Return freqDist
End Function
Private Sub ShowResults(ByVal fd As Integer(), ByVal w As Integer)
Dim sb As StringBuilder = New StringBuilder("")
Dim cumProb As Double = 0.0
For i As Integer = 0 To fd.GetUpperBound(0)
Dim low As Integer = i * w
Dim high As Integer = low + w  1
Dim relProb As Double = fd(i) / nudTrials.Value * 100
cumProb += relProb
sb.Append(String.Format("{0,3}  ", low))
sb.Append(String.Format("{0,3}", high))
sb.Append(String.Format(" {0,5}", fd(i)))
sb.Append(String.Format(" {0,7:F}", relProb.ToString))
sb.Append(String.Format(" {0,7:F}", cumProb.ToString))
sb.Append(Environment.NewLine)
Next
txtResults.Text = sb.ToString()
End Sub
Private Sub btnNextDeviate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextDeviate.Click
Dim norm As NormalDistribution = New NormalDistribution()
txtNextDeviate.Text = CInt(norm.Deviate()).ToString()
End Sub
End Class
'
' Code for NormalDistribution class
'
Public Class NormalDistribution
Private uniformGenerator As Random
Public Sub New()
uniformGenerator = New Random()
End Sub
Public Sub New(ByVal seed As Int32)
uniformGenerator = New Random(seed)
End Sub
Public Function Deviate(Optional ByVal mean As Double = 100.0, Optional ByVal sigma As Double = 20.0) As Double
Dim dev As Double
dev = sigma * StandardDeviate() + mean
Return dev
End Function
Public Function StandardDeviate() As Double
'Returns a value from ~N(0, 1).
'Requires a generator that produces ~U(0, 1)  uses built in Random for this
'Calculates two values, one is returned; other returned on next call.
Static haveDeviate As Boolean = False
Static nextDeviate As Double
Dim factor As Double
Dim sumOfSquares As Double
Dim uniform1 As Double
Dim uniform2 As Double
If (Not haveDeviate) Then
Do
uniform1 = 2.0 * uniformGenerator.NextDouble()  1.0
uniform2 = 2.0 * uniformGenerator.NextDouble()  1.0
sumOfSquares = uniform1 * uniform1 + uniform2 * uniform2
Loop While (sumOfSquares >= 1.0 OrElse sumOfSquares = 0.0)
factor = Math.Sqrt(2.0 * Math.Log(sumOfSquares) / sumOfSquares)
nextDeviate = uniform1 * factor
haveDeviate = True
Return uniform2 * factor
Else
haveDeviate = False
Return nextDeviate
End If
End Function
Public Function ApproxDeviate(Optional ByVal mean As Double = 100.0, Optional ByVal sigma As Double = 20.0) As Double
Dim v As Double
v = sigma * StandardDeviate() + mean
Return v
End Function
Public Function ApproxStdDeviate() As Double
'Approximates Normal with average of Uniform in range 0.5 to 0.5
'Requires a generator that produces ~U(0, 1)  uses built in Random for this
Dim sum As Double
Dim count As Integer = 20
For i As Integer = 1 To count
sum += uniformGenerator.NextDouble()  0.5
Next
Return sum / count
End Function
End Class
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Sunday, August 15, 2010 11:58 AM 
"Rather, we speak of a sequence of independent random numbers with a specified distribution , and this means loosely that each number was obtained merely by chance, having nothing to do with other numbers of the sequence, and that each number has a specified probability of falling in any given range of values.
A uniform distribution on a finite set of numbers is one in which each possible number is equally probable. A distribution is generally understood to be uniform unless some other distribution is specifically mentioned. " Knuth, TAOCP, Vol. II, Chap. 3
If I take the two paragraphs together, then paragraph 1 can be rewritten to say;
Rather, we speak of a sequence of independent random numbers with a uniform distribution , and this means loosely that each number was obtained merely by chance, having nothing to do with other numbers of the sequence, and that each number has a specified probability of falling in any given range of values.
This was clearly what he meant.
Also, Knuth seems to have several criteria for randomness, one of which is the "merely by chance" clasue. Adding the values on the face of two dice is not merely by chance is it?
Lets play a random game per your definition. We have a lotto machine with 3 balls in it. One ball has "A" on it. Two balls have "B". We will do 1000 draws, replacing the drawn ball each time, counting A or B. I get to pick first, and I pick B, which means you get A. The winner is the one with the highest count. The loser has to change his mind ;)
"But random does not mean uniformly distributed, which is what both you, Renee, and Knuth claim."Perhaps what NIST meant by binary sequence where numbers generated by computers.
Subnet Calculator / Planner Serial Port Random Edited by dbasnett Sunday, August 15, 2010 3:38 PM
Sunday, August 15, 2010 2:01 PM 
'requires code from fourth post
Private Sub Button9_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button9.Click
Dim myBS As Integer 'used to hold a binary sequence
'The key is the binary sequence produced
Dim BS As New SortedDictionary(Of String, Integer)
Const Tries As Integer = 100000 'number of binary sequences produced
RichTextBox1.Clear()
For x As Integer = 1 To Tries
'create a binary sequence
myBS = PRNG.Next(256)
Dim k As String = Convert.ToString(myBS, 2).PadLeft(8, "0"c)
'calc results
If BS.ContainsKey(k) Then
BS(k) += 1
Else
BS.Add(k, 1)
End If
Next
'show results
For Each kvp As KeyValuePair(Of String, Integer) In BS
RichTextBox1.AppendText(String.Format("BS {0} Prob. {1}{2}", _
kvp.Key, _
(kvp.Value / Tries).ToString("p2"), _
Environment.NewLine))
Next
End Sub
Subnet Calculator / Planner Serial Port RandomSunday, August 15, 2010 2:44 PM 
If I take the two paragraphs together, then paragraph 1 can be rewritten to say;
It cannot be rewritten in the way you claim. I could rewrite it as "Rather, we speak of a sequence of independent random numbers with a Normal distribution " but that would be equally wrong. He says the distribution has to be specified not that it is uniform. If he had wanted to say that he would have said it. What he says is, if the distribution is unspecified, then it is generally understood to be uniform. "Generally understood" does not mean always the case. It just means if you have not specified the distribution then people will usually assume you mean a uniform one. As I said before, the first paragraph gives the meaning of "a sequence of random numbers"; the second, defines the uniform distribution. You can only rewrite the first paragraph the way you have if you assume random means uniformly distributed, and that's begging the question.
Knuth does have several criteria because you need several criteria:
1. The outcome of each trial is not affected by previous outcomes (independence)
2. There is no systematic selection procedure (chance selection)
3. Each possible outcome has a specified probability (but there is no requirement that all possible outcomes have the same probability). The probability may be specified on empirical grounds (e.g. using relative frequencies from previous experiments), theoretically, or subjectively (which usually leads to equal probabilities e.g. we have no reason to believe heads is more probable than tales)
Processes that generate numbers that meet these criteria are random processes, the numbers they produce are random numbers.
As to the game, why do I get A when you pick B? What if you pick A first? What if I go first? This is more akin to Find The Lady  it's rigged from the start hence in no way random. I'm actually struggling with this because the scoring is unclear. Furthermore, in your terms it's not a random game since the probabilities of A and B are not uniform (B is twice as likely to be chosen as A).
Unfortunately, Knuth does not answer emails so we have no way of confirming your claim that he thinks random means uniformly distributed.
NIST mean a sequence of 0s and 1s (effectively same as heads and tails when tossing a coin), they take it that the sequence is generated by a computer but the tests could be applied to any process that produces a binary sequence.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Sunday, August 15, 2010 3:12 PM 
I guess I could try contacting Knuth. If nothing else it would provide him with more scrap paper.
Subnet Calculator / Planner Serial Port RandomSunday, August 15, 2010 3:46 PM 
If I take the two paragraphs together, then paragraph 1 can be rewritten to say;
It cannot be rewritten in the way you claim. I could rewrite it as "Rather, we speak of a sequence of independent random numbers with a Normal distribution " but that would be equally wrong. He says the distribution has to be specified not that it is uniform. If he had wanted to say that he would have said it. What he says is, if the distribution is unspecified, then it is generally understood to be uniform. "Generally understood" does not mean always the case. It just means if you have not specified the distribution then people will usually assume you mean a uniform one. As I said before, the first paragraph gives the meaning of "a sequence of random numbers"; the second, defines the uniform distribution. You can only rewrite the first paragraph the way you have if you assume random means uniformly distributed, and that's begging the question.
Knuth does have several criteria because you need several criteria:
1. The outcome of each trial is not affected by previous outcomes (independence)
2. There is no systematic selection procedure (chance selection)
3. Each possible outcome has a specified probability (but there is no requirement that all possible outcomes have the same probability). The probability may be specified on empirical grounds (e.g. using relative frequencies from previous experiments), theoretically, or subjectively (which usually leads to equal probabilities e.g. we have no reason to believe heads is more probable than tales)
Processes that generate numbers that meet these criteria are random processes, the numbers they produce are random numbers.
As to the game, why do I get A when you pick B? What if you pick A first? What if I go first? This is more akin to Find The Lady  it's rigged from the start hence in no way random. I'm actually struggling with this because the scoring is unclear. Furthermore, in your terms it's not a random game since the probabilities of A and B are not uniform (B is twice as likely to be chosen as A).
Unfortunately, Knuth does not answer emails so we have no way of confirming your claim that he thinks random means uniformly distributed.
NIST mean a sequence of 0s and 1s (effectively same as heads and tails when tossing a coin), they take it that the sequence is generated by a computer but the tests could be applied to any process that produces a binary sequence.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.
I contend that the addition of the values resulting from the throw of two dice is a systematic selection procedure.Okay, since you contend throwing dice and adding the result is random, lets change the game to that. Pick the number (we can't both pick the same number) that will appear most often in 1000 rolls. I get to pick first, I pick 7. I get to pick first since I am trying to disprove your theory "...random does not mean uniformly distributed...".
Subnet Calculator / Planner Serial Port RandomSunday, August 15, 2010 3:55 PM 
"But random does not mean uniformly distributed, which is what both you and Renee claim."
No, I have not claimed that. I have said that random distributions are equiprobable and that is all I have said. A random distribution will not be achieved unless the sample is uniform, meaning equiprobability. So you have to talk about randomness in terms of the distribution that is sampled AND the process used to select the sample as well as what the distribution looks like or is.
Renee
Sunday, August 15, 2010 3:57 PM 
I guess I could try contacting Knuth. If nothing else it would provide him with more scrap paper.
Subnet Calculator / Planner Serial Port Random
Email sent to the specified address. My guess is that Prof. Knuth has more scrap paper, but you never know.
Subnet Calculator / Planner Serial Port RandomSunday, August 15, 2010 4:47 PM 
random distributions are equiprobable
Does that not mean uniform?
I think I can see part of the problem in the talk of "random distributions" (something I'm probably just as guilty of).
Strictly speaking, no distribution is random since a distribution is a set of values with their related probabilities (or relative frequencies). As such it's not strictly correct to speak of "random distributions". We should really talk about probability or frequency distributions.
What can be random is a sequence of values drawn from a distribution. To be a random sequence, it must meet certain criteria which include independence and chance. Furthermore the relative frequencies of values in the sequence must be (approximately) the same as in the distribution the values are drawn from. If the values do not meet these criteria then we conclude the sequence is not random.
Now I think this amounts to the same as what you say in:
So you have to talk about randomness in terms of the distribution that is sampled AND the process used to select the sample as well as what the distribution looks like or is.
If that is the case then there is no disagreement. The apparent disagreement is because I have taken other posts to claim that the underlying distribution must be uniform to generate a sequence of random values. If that is not the claim then it's my mistake to take it as such.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Sunday, August 15, 2010 5:04 PM 
I contend that the addition of the values resulting from the throw of two dice is a systematic selection procedure.
I assume the systematic part is the addition since the dice rolling is unsystematic. If so go back to my bag of 36 balls (where one ball is numbered 2, two balls are numbered 3, ... one ball is numbered 12). The 36 balls are placed in a bag and shaken, a ball is withdrawn, its number noted, the ball is replaced and the process repeats.To show that this will not produce a random sequence of numbers (between 2 and 12) you have to show that one of the following criteria are not met:
1. Independence  i.e. show that on a particular draw the number drawn depends on previous numbers, e.g. the probability of getting 12 on the next draw rises to 1/2 if you have just drawn a 7.
2. Chance  i.e. show that there is something that results in some ball(s) being drawn preferentially (and consider the labeled balls below before answering).
3. The sequence reflects the underlying distribution  i.e. show that there will be an excess or deficit of e.g. 4s when compared with the expected frequency of 3/36 (or any other number, and its expected frequency, you care to choose).
Now suppose the balls are also labeled with each ball having a one or two letter label i.e. A, B, C,...AA, AB,...AJ. (The label bears no relation to the number  I could just put them in the bag and draw them out (without replacement) and label them A, B, C... as I go). Suppose I carry out a number of draws as before and that I record the number and the label separately. I will find that the numbers form a sequence that is not uniformly distributed (I expect 7 to occur more often than 12). However, the labels will be uniformly distributed (I expect as many As as Bs as Cs... as AJs). So, will you claim that the sequence of labels is random but the sequence of numbers is not when both result from the same experiment?
In terms of statistics, this exactly reflects the situation where each trial outcome is the result of rolling two dice.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Sunday, August 15, 2010 5:48 PM 
"But random does not mean uniformly distributed, which is what both you, Renee, and Knuth claim."
No. I have not claimed that.
I've said that one must specify the sampling distributon, the process and the (output) distribution before any statement may be made. I have also said that I don't know how a set of random numbers can come from a nonrandom distribution. Random means equiprobility with in a distribution. I believe that because of equiprobabilty the distribution has to be uniformly distributed.
Actually, as I look at this statement: "random does not mean uniformly", it is not defined.
Renee
Sunday, August 15, 2010 9:26 PM 
"If that is the case then there is no disagreement. The apparent disagreement is because I have taken other posts to claim that the underlying distribution must be uniform to generate a sequence of random values. If that is not the claim then it's my mistake to take it as such."
David,
I am coming to the conclusion that you indeed must draw from a random sample in order to generate a random distributuon with a random process.
Renee
Sunday, August 15, 2010 9:33 PM 
"So, will you claim that the sequence of labels is random but the sequence of numbers is not when both result from the same experiment?"
Yes.
My offer to play any of your random games stands. If the balls are more to your liking so be it. I'll take 7 again.
Subnet Calculator / Planner Serial Port RandomMonday, August 16, 2010 12:31 AM 
If the sequence of labels is random, but the sequence of numbers is not then what is the difference?
The outcomes in both sequences meet the criteria for randomness: any outcome is independent of previous outcomes, outcomes occur by chance, outcomes have specified probability distributions. So, as far as I can see, both are random. Unless you have some other criteria that must be met to make the one random and the other nonrandom.
The offer to play any game is a distraction, whether or not I agree to play the game does not affect the randomness of the sequence. As you have set it up (so that the number of successes is counted and the one with the highest count wins) then obviously if someone can choose 7 (and stick with it) then they are the likely winner. However, consider the more usual game where you have to bet on the next number to be drawn. If you are correct you win a dollar otherwise yo lose a dollar. Will you end up winning or losing? Is there a winning strategy? If not then the sequence would meet Von Mises's Axiom Of Randomness, so under the relative frequency approach to probability the sequence would be random.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Monday, August 16, 2010 9:21 AM 
One of the outcomes obviously does not occur by chance. You eliminated chance by having the same number multiple times.
The letters uniquely identify a particular ball and the count of which lettered ball was selected is the random test.
This is what I believed when I started this thread.
If I have a set of 10 uniquely identified items and make 1000 random selections from that set, each uniquely identified item will be selected about 100 times.
This is what I still believe.
Subnet Calculator / Planner Serial Port RandomMonday, August 16, 2010 1:20 PM 
One of the outcomes obviously does not occur by chance. You eliminated chance by having the same number multiple times.
That rules out a huge swathe of statistics: you cannot get a random sample of peoples' heights because the same height occurs multiple times, nor incomes, nor weights, nor defects in batches (two batches can have the same number of defects) etc. Or so it seems to me if you insist the underlying distribution must be uniform. It also rules out a whole bunch of statistical theory concerning Poisson, Binomial, Exponential, Normal and other distributions since they are not uniform, yet the theory is developed on the basis of random selections from these distributions. That's too high a price to pay if I was to accept your view.
To me the outcomes are both obviously 'by chance' neither depends on previous outcomes, nor is there anything in the selection process that favors any particular ball hence any particular number when a selection is made.
However, I can see that any argument I present will not make you change your mind.
On another topic, did you see the NormalDistribution code I posted? You're welcome to use it or ignore is as you see fit. I've also had a play with doing a 'Bag Of Balls' simulation if you're interested.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Monday, August 16, 2010 8:05 PM 
"That rules out a huge swathe of statistics: you cannot get a random sample of peoples' heights because the same height occurs multiple times, nor incomes, nor weights..." The sample can be taken randomly, and the results will reflect the population of the set. The underlying set(approx. 7B) is uniform and unique but the labels affixed to the members of the set is not. (weighted random selection)
Subnet Calculator / Planner Serial Port RandomTuesday, August 17, 2010 2:51 PM 
The underlying set(approx. 7B) is uniform and unique
I don't believe you mean that. Think of it this way: I have a set of balls, on each ball I write a label identifying the person and the person's height. The labels identify individuals so they are unique. However the heights will vary and will include multiple copies of the same values (unless no two people are the same height). I carry out an experiment where I draw a number of balls (with replacement) and note the heights. So the underlying distribution is that of the distribution of heights (that's the value of interest in the experiment and the only one recorded). You claim that this is not a random sample of heights because the distribution of heights is nonrandom (or contains duplicates). At least that's what I think you claimed about the 36 ball experiment. But this is exactly the same except for the number of balls. So any statistical conclusions drawn from the results of this experiment are invalid because it is a non random sample. Yet this mirrors the way many statistical experiments are performed so we have t dismiss those as invalid.
but the labels affixed to the members of the set is not.
The labels are unique by design, it is the numbers/heights that are not unique but form a nonuniform distribution. And it is the numbers that are the variable that is under consideration.
Consider also the Binomial Distribution. This is one where there are two possible mutually exclusive outcomes. The outcomes are usually deemed Success (with probability p) and Failure (with probability q). The restrictions are that 0<=p<=1 and q=1p. E.g suppose I consider Success as getting 6 on a single throw of a die, then p=1/6, q=5/6. Suppose I throw a die a large number of times and record Success as 1 and Failure as 0. The distribution of results is clearly nonuniform there will be approximately 5 times as many 0s as 1s (hence in your terms non random). Now I can use results about the Binomial Distribution to calculate the probability of getting say exactly 4 success in 20 throws. But only under the assumption that the sequence of success/failure is random. If the distribution must be uniform to ensure randomness that means I can only apply the Binomial calculation s where p=q=1/2. So my calculate probabilities would be invalid in the case of throwing a single die. Yet any introductory textbook on statistics will disagree with that.
You would also have to rule out the use of the Binomial distribution in e.g. quality control where success is usually defined as finding a defect. This allows you to calculate the probability of 0 defects, 1 defect, 2 defects... occurring if you know the batch size and the defect rate. And you can do that whether the defect rate is 1% or 50%, or some other fraction, but typically much less than 50% (i.e. where numbers of defects has decidedly nonuniform distribution).
I was going to make my previous post the last one on this issue because I don't think you'll change your mind. And I won't change mine because I'm obviously right! (a statement to be taken with a large pinch of salt). :).
From my point of view this has been a good debate. We have both stated what we believe to be the case and tried to counter each others objections. No vitriol or personal attacks just punch and counterpunch leading to draw (or perhaps points victory for one of us, that's for other people to judge).
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Tuesday, August 17, 2010 4:46 PM 
"The underlying set(approx. 7B) is uniform and unique but the labels affixed to the members of the set is not. (weighted random selection)" The set of "people on planet earth" represents a uniform and unique set. All I meant was that the set was 1  7B (each member of the set has a unique identifier label, i.e. Person 1, Person 2, Person 3, ... Person 6,587,369,042). I do not have a problem with the set having other labels.
The chance I will be selected is a random process. I have a 1 in 7B(approx.) chance of being selected.
If you randomly sample the population and tabulate the results of the sample's other labels (____, race, income, height, weight, etc) they will not be random(nor should they) because the original set of those labels was not random. The unique identifier labels will be.
Sincerely,
Person 4,242,424,242
Other labels  ????????
edit  The forum substituted ____ for a word that started with s, ended with x and had one other letter (e), between them. ;)
Subnet Calculator / Planner Serial Port RandomTuesday, August 17, 2010 5:32 PM 
How do I get a random set of heights?
Suppose I wanted to compare heights of New York males with those of males in Dubai. To do that I need a random sample of NY male heights and one of Dubai male heights. How do I get a random sample of heights for each city?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Tuesday, August 17, 2010 5:50 PM 
How do I get a random set of heights?
Suppose I wanted to compare heights of New York males with those of males in Dubai. To do that I need a random sample of NY male heights and one of Dubai male heights. How do I get a random sample of heights for each city?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.
42
Subnet Calculator / Planner Serial Port RandomTuesday, August 17, 2010 5:55 PM 
I crack me up! Let me see if i can make a simple statement that we can agree on.
A random selection is not the same as a weighted random selection.
Subnet Calculator / Planner Serial Port RandomTuesday, August 17, 2010 6:03 PM 
Last question.
I get the heights of a large number of people using whatever method you consider random. I write each height on a ball, place all the balls in a bag, shake it and then withdraw them one at a time (no replacement).
As I withdraw a ball I write the height on the ball to form a sequence of numbers.
Is that sequence random? In other words, is each number independent, drawn by chance and from a probability distribution (which is not uniform given the distribution of heights)?
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Tuesday, August 17, 2010 9:07 PM 
I presume that there will be heights that are the same since you are trying to prove something. The sequence of numbers will be a weighted random sequence. If the balls also have unique labels and you use those numbers they will be a random sequence. How many times are you going to try? to convince me?
Subnet Calculator / Planner Serial Port RandomTuesday, August 17, 2010 10:23 PM 
There is a difference between:
A. Choosing a random sample from a given population
and
B. Generating a sequence of random numbers with a given distribution.
You have been talking about A; I have been talking about B. If you go back to the 36 labeled balls. Each draw represents picking a random sample of size 1 from the population of 36 balls. The random samples are used to generate a random sequence of numbers (2 to 12) that come from a non uniform probability distribution.
I presume that there will be heights that are the same since you are trying to prove something.
I was not actually trying to prove something by the last question. I was trying to determine if you recognized the difference between A and B. But I cannot be sure since you did not answer the question directly.
The sequence of numbers will be a weighted random sequence .
I've never come across the concept of a weighted random sequence. I have come across weighted random samples.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Wednesday, August 18, 2010 5:47 AM 
Dbasnett,
I see nowhere in your text that if the first card is taken from a deck of 52 charts you have 52 chances.
If that is done then you have 51 chances.
So the random possible number becomes every time less based on the remaining sequence.
This is why casinos tell you are not allowed to count with card games, but in fact it is one of the important things in most card games like Bridge and basically of all card games.
That is why a roulette wheel should never have a whatever failure, for instance not being horizontal, that would influence the chance on a random result.
For me completely random means a result not influenced by whatever other situation (not even the position of the sun).
Therefore completely random is impossible, because the sun will influence the way a dice rolls even if that is very slightly.
Therefore it is more what tolerance do we have to call it random.
Success
CorWednesday, August 18, 2010 7:40 AM 
"For me completely random means a result not influenced by whatever other situation (not even the position of the sun)."
Cor, the word "random" is well defined and personal meaning does not make much difference. It was well defined in the sixties even.
Renee
Wednesday, August 18, 2010 3:12 PM 
Here http://www.codeproject.com/KB/recipes/SimpleRNG.aspx?fid=1206777&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=1#xx0xx is some evidence that I am not alone in thinking you can generate non uniform random sequences. This project generates sequences from 10 different distributions (including uniform). Interestingly (or perhaps not), none of the comments question the validity of generating non uniform sequences. :)
The code is in C# and you need to be registered with CodeProject to download it, but the article explains what it does.
Regards David R  "Every program eventually becomes rococo, and then rubble."  Alan Perlis The only valid measurement of code quality: WTFs/minute.Wednesday, August 18, 2010 4:17 PM 
For your amusement
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim foo As New Dice() 'standard game 2, 6 sided dice
'Dim foo As New Dice(2, 1) 'as a coin
Dim dt As DateTime = DateTime.Now
Debug.WriteLine(dt.ToString("HH:mm:ss.ffff"))
Const tries As Integer = 1000000
For x As Integer = 1 To tries 'throw dice
foo.RollAll()
'For Each d As die In foo.GetDice
' Debug.WriteLine(d.CurrentFace)
'Next
'Debug.WriteLine("Total " & CrapsDice.Total.ToString)
Next
Dim rolls As Long = foo.GetRolls
Debug.WriteLine(rolls.ToString("N0") & " took " & (DateTime.Now  dt).TotalMilliseconds & " ms.")
Dim stats As Dictionary(Of Long, Integer) = foo.GetStats 'get the stats
Dim chkCT As Long = 0L
For Each kvp As KeyValuePair(Of Long, Integer) In stats
Debug.WriteLine(String.Format("{0}  occurred {1} times ({2})", _
kvp.Key.ToString, _
kvp.Value.ToString, _
(kvp.Value / rolls).ToString("P2")))
chkCT += kvp.Value
Next
'If chkCT <> rolls OrElse chkCT <> tries Then Stop
End Sub
End Class
Public Class Dice
Private Shared PRNG As New Random 'one pseudo random generator
Private _theDice As Dictionary(Of Integer, die) 'a collection of items
Private _total As Long = 0 'the total for all items
Private _keepStats As Boolean = True 'keep stats?
Private _theStats As Dictionary(Of Long, Integer) 'the stats
Private _rolls As Long = 0L 'number of rolls / throws / flips / etc.
Public Sub New()
'the default constructor  2 dice, 6 faces
Me.New(6, 2)
End Sub
Public Sub New(ByVal Faces As Integer, ByVal NumOfDie As Integer)
If Faces < 2 OrElse NumOfDie < 1 Then Throw New ArgumentException
Me._theDice = New Dictionary(Of Integer, die) 'create storage for the dice
For dieNum As Integer = 1 To NumOfDie 'create a die for each
Dim aDie As New die 'a new die
aDie.Faces = Faces 'set the number of faces
Me._theDice.Add(dieNum, aDie) 'add to collection
Next
'init stats
Me._theStats = New Dictionary(Of Long, Integer)
For dienum As Long = NumOfDie To NumOfDie * Faces
Me._theStats.Add(dienum, 0) 'add bucket, count = 0
Next
End Sub
Public Sub RollAll() 'roll all dice in collection
Me._total = 0L 'accumulate total when rolling all
For Each d As Integer In Me._theDice.Keys
Me._theDice(d).CurrentFace = Dice.PRNG.Next(1, Me._theDice(d).Faces + 1)
Me._total += CLng(Me._theDice(d).CurrentFace)
Next
'if keeping stats increment count
If Me._keepStats Then
Me._theStats(Me._total) += 1 'inc. count
Me._rolls += 1L 'inc. roll count
End If
End Sub
Public Sub Roll1(ByVal theDieToRoll As Integer)
'roll a die
Me._theDice(theDieToRoll).CurrentFace = Dice.PRNG.Next(1, Me._theDice(theDieToRoll).Faces + 1)
End Sub
ReadOnly Property Total As Long 'return total
Get
Return Me._total
End Get
End Property
ReadOnly Property GetDice As List(Of die) 'return the dice
Get
Return Me._theDice.Values.ToList
End Get
End Property
Property StatsOnOff As Boolean 'turn stats on / off
Get
Return Me._keepStats
End Get
Set(ByVal value As Boolean)
'reset rolls when going from false to true
If value = True AndAlso Me._keepStats = False Then Me._rolls = 0L
Me._keepStats = value
End Set
End Property
ReadOnly Property GetStats As Dictionary(Of Long, Integer) 'return the stats
Get
Return Me._theStats
End Get
End Property
ReadOnly Property GetRolls As Long 'return the rolls
Get
Return Me._rolls
End Get
End Property
End Class
Public Class die
Private _faces As Integer = 1 'the number of faces this die
Private _curFace As Integer = 1 'the current face of this die
Public Property Faces As Integer
Get
Return Me._faces
End Get
Set(ByVal value As Integer)
Me._faces = value
End Set
End Property
Public Property CurrentFace() As Integer
Get
Return Me._curFace
End Get
Set(ByVal value As Integer)
Me._curFace = value
End Set
End Property
End Class
Subnet Calculator / Planner Serial Port RandomSaturday, August 21, 2010 7:04 PM 
"For me completely random means a result not influenced by whatever other situation (not even the position of the sun)."
Cor, the word "random" is well defined and personal meaning does not make much difference. It was well defined in the sixties even.
Renee
Where was it, because in my idea there is not a real definition for completely random. Although the sixties is rather young, was that on your elementary school, otherwise do a contribution and show us the link to the definition?
The Chinese started with investigations around this phenomena about 3000 years ago like is written on Wikipedia.
Success
CorMonday, August 23, 2010 8:51 AM 
There is no definitiom for a nontechnical word, but random number's were well defined in a one year statistics course that I took in undergraduate school in the psychology department at Old Dominion University by Dr. David Pancoast. I've already named the text by Runion and Haber in this thread. There is quite a study in it.
Renee
Monday, August 23, 2010 2:44 PM 
I guess I could try contacting Knuth. If nothing else it would provide him with more scrap paper.
Subnet Calculator / Planner Serial Port Random
Email sent to the specified address. My guess is that Prof. Knuth has more scrap paper, but you never know.
Subnet Calculator / Planner Serial Port Random
Subnet Calculator / Planner Serial Port RandomFriday, October 8, 2010 12:48 PM 
Relevant comments from Professor Knuth were added to post #1. I think I will decline his offer of "some scrap paper for you." ;)
Subnet Calculator / Planner Serial Port RandomSaturday, October 16, 2010 8:41 PM