Search   Memberlist   Usergroups
 Page 6 of 8 [110 Posts] View previous topic :: View next topic Goto page:  Previous  1, 2, 3, 4, 5, 6, 7, 8 Next
Author Message
Reef Fish
science forum Guru Wannabe

Joined: 28 Apr 2005
Posts: 200

Posted: Thu Jun 09, 2005 8:23 pm    Post subject: Re: Probability question, was Re: Mensa Forgot Another Possibility!

Scott Hemphill wrote:
 Quote: "Mark" writes: "BruceS" wrote in message news:1118264621.238754.254340@f14g2000cwb.googlegroups.com... I wouldn't be at all offended if you reposted there and returned here with any answers. I try to avoid crossposting, especially to groups I don't follow. Here then is the question as I remember it: on consideration this may not be precisely on topic for sci.stat.math although I suppose that in general people who are up on stats are up on probability too. A student sits a test that has 20 questions; every question has precisely 1 matching answer. There are 20 answers, no duplication. The student answers every question with a different answer from the 20. What is the probability, of a student answering randomly, answering precisely 1 right? precisely 10 right? This problem is treated in _Concrete Mathematics_ by Graham, Knuth and Patashnik. They call it the "'football victory problem': a group of n fans of the winning football team throw their hats high into the air. The hats come back randomly, one hat to each of the n fans. How many ways h(n,k) are there for exactly k fans to get their own hats back?" They derive a closed form solution for the answer: h(n,k) = choose(n,k) * subfactorial(n-k) where choose(n,k) = nCk = n!/((n-k)!k!) and subfactorial(n) is the number of derangements of n objects, i.e. the number of permutations for which none of objects are in their original position. subfactorial(n) is further developed: subfactorial(n) = round(n!/e) + [n==0] where round is the function which rounds to the nearest integer and the bracket notation yields 1 if the boolean expression inside is true and 0 if the boolean expression is false. I've used == for the equality operator, and e is Euler's constant e = 2.71828....

All things aside, why are you calling e = exp(1) Euler's constant?

Euler's constant is the limit (as n goes to infinity) of
1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/n - log n.

=0.57721566 4901532860 6065120900 8240243104 2159335939 9235988057 ...

The other numerical values and statements are correctl.

-- Bob.

 Quote: The values of h(n,k) for n = 20: k h(20,k) -- ------- 0 895014631192902121 1 895014631192902120 2 447507315596451070 3 149169105198816960 4 37292276299704525 5 7458455259939936 6 1243075876659240 7 177582268088640 8 22197783520770 9 2466420377200 10 246642054516 11 22421988160 12 1868513010 13 143722080 14 10271400 15 682176 16 43605 17 2280 18 190 19 0 20 1 The exact probability of each "k" occurring is calculated by dividing each of these values by 20!. Scott -- Scott Hemphill hemphill@alumni.caltech.edu "This isn't flying. This is falling, with style." -- Buzz Lightyear
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

Posted: Thu Jun 09, 2005 8:32 pm    Post subject: Re: Probability question

From rec.org.mensa
anyone got a slicker solution ??
' - - - - - - - - - - - -

On Thu, 9 Jun 2005 13:56:11 +0200, "Mark"
<Markiehatesspam@notelespam2.fr> wrote:

 Quote: "BruceS" wrote in message news:1118264621.238754.254340@f14g2000cwb.googlegroups.com... I wouldn't be at all offended if you reposted there and returned here with any answers. I try to avoid crossposting, especially to groups I don't follow. Here then is the question as I remember it: on consideration this may not be precisely on topic for sci.stat.math although I suppose that in general people who are up on stats are up on probability too. A student sits a test that has 20 questions; every question has precisely 1 matching answer. There are 20 answers, no duplication. The student answers every question with a different answer from the 20. What is the probability, of a student answering randomly, answering precisely 1 right? precisely 10 right? Mark ' - - -

Getting 1 right: 0.3679
Getting 10 right: 0.01378 * 10^(-7)
'- - - -
P(n,x) is prob getting x right out of n

Q(n,y) is prob of getting y right, with n 'good' questions plus one
'dummy' question (cannot be matched),

P(n,x) = P(n-1,x-1)/n + (n-1)*Q(n-2,x)/n

Q(n,y)=P(n,y)/(n+1) + n*Q(n-1,y)/(n-1)

P(n,n)=1/n!
P(n,n-1)=0
' - -
VB.net -- form1 has one button, Button1

' - - -
Form1:

Imports System.Math
Public Class Form1
Inherits System.Windows.Forms.Form

Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i, j, iii, jjj, ii, jj As Integer
ReDim P(100, 100)
ReDim Q(100, 100)
P(1, 1) = 1
P(1, 0) = 0
Q(1, 1) = 0.5
Q(1, 0) = 0.5
Q(0, 0) = 1
' - - - - - -
For n = 2 To 20
P(n, n) = 1
For jj = 2 To n
P(n, n) = P(n, n) * jj
Next
P(n, n) = 1 / P(n, n)
' - -
P(n, n - 1) = 0
pstr = n & " p " & P(n, n) & " " & P(n, n - 1) & " "
For x = n - 1 To 0 Step -1
' if we got a hit on first try
If x < n - 1 Then
P(n, x) = 0
If (x > 0) Then P(n, x) = P(n - 1, x - 1) / n
If n > 1 Then P(n, x) = P(n, x) + _
(n - 1) * Q(n - 2, x) / n '(n-1)/n is the prob of
no hit
' Q(n-2,x) is prob - with n-2 questions and 1
dummy -
' we match correctly to x out of n-1 answers plus
one dummy
' the answer dummy comes because we just used up
the right question for it,
' and the question dummy comes because we have knocked
out the right answer to it
pstr = pstr & " " & P(n, x)
End If
Next
If n = 20 Then MsgBox(pstr)
' - - -
For y = n To 0 Step -1
Q(n, y) = P(n, y) / (n + 1)
If n > 1 Then Q(n, y) = Q(n, y) + n * Q(n - 1, y) / (n
+ 1)
'if we do match 'on the first -dummy question - try,
prob 1/(N+1), then we are left with
' n good questions and n good answers
'n/(n+1) is the prob of not matching dummies
' if we dont match, then we have lost the question
dummy, but another has been created
'- it doesnt have a correct answer anywhere
' -so we are at n-1 questions + 1 dummy
'we have knocked out a good answer (for the new dummy
question) so we have n-1 answers
' plus the original dummy
Next
Next
End
End Sub
End Class
' - - - - - - - -
Module global
Public Q(,), P(,) As Single
Public n, x, y As Integer
Public pstr As String
End Module

>
Scott Hemphill
science forum beginner

Joined: 09 Jun 2005
Posts: 21

Posted: Fri Jun 10, 2005 12:34 am    Post subject: Re: Probability question, was Re: Mensa Forgot Another Possibility!

"Reef Fish" <Large_Nassau_Grouper@Yahoo.com> writes:

 Quote: Scott Hemphill wrote: where round is the function which rounds to the nearest integer and the bracket notation yields 1 if the boolean expression inside is true and 0 if the boolean expression is false. I've used == for the equality operator, and e is Euler's constant e = 2.71828.... All things aside, why are you calling e = exp(1) Euler's constant?

A mental lapse. I stand corrected.

 Quote: Euler's constant is the limit (as n goes to infinity) of 1 + 1/2 + 1/3 + 1/4 + 1/5 + ... + 1/n - log n. =0.57721566 4901532860 6065120900 8240243104 2159335939 9235988057 ...

Yes, I am familiar with this constant.

Scott
--
Scott Hemphill hemphill@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

 Posted: Fri Jun 10, 2005 2:38 pm    Post subject: Re: Probability question Q(n,y)=P(n,y)/(n+1) + n*Q(n-1,y)/(n-1) should be Q(n,y)=P(n,y)/(n+1) + n*Q(n-1,y)/(n+1) - the code is correct
Martin Evans
science forum beginner

Joined: 10 Jun 2005
Posts: 3

Posted: Fri Jun 10, 2005 2:54 pm    Post subject: Re: Probability question

alan truelove wrote:

 Quote: From rec.org.mensa anyone got a slicker solution ?? ' - - - - - - - - - - - - A student sits a test that has 20 questions; every question has precisely 1 matching answer. There are 20 answers, no duplication. The student answers every question with a different answer from the 20. What is the probability, of a student answering randomly, answering precisely 1 right? precisely 10 right?

I think one possible way of visualising this problem is to think of it as a
20x20 matrix, with the rows representing the questions and the columns
representing the answers; a cell is marked (with an 'x', say) to show that a
certain question has been assigned to a certain answer. A valid test outcome
has each row and each column containing exactly one 'x'. An 'x' on the leading

Let's generalise the problem to T tests and R right answers, and let's suppose
we don't have to consider the order in which the questions are answered - we are
only interested in the outcome.

The total number of possible test outcomes is thus Nt = T! This is arrived at
by arguing that the 'x' in the first column has a choice of 20 cells, the second
a choice of 19 cells etc.

The number of ways, Nr, of generating exactly R right answers is the product of
the number of ways of scattering R 'x's down the leading diagonal, Nd, and the
number of ways of filling in the remaining columns with 'x's *off* the leading
diagonal, No.

We would have Nd = T!/((T-R)! * R!) as this is the number of different ways of
arranging R things in T places, regardlessof order.

Then we have T-R columns left, each of which has the cell on the leading
diagonal forbidden to us, as well as the rows already containing 'x's for right
answers. The first column we add an 'x' to would thus have (T-R-1) valid cells
available. So we would have No = (T-R-1)! using a similar argument as that for
Nt.

The chance, Pr, of getting *exactly* R right answers in T tests is therefore
Nr/Nt = (Nd * No) / Nt = (T! * (T-R-1)!) / (T! * (T-R)! * R!)

Simplifying the above expression, we get:

Pr = (T-R-1)! / (R! * (T-R)!)

For T = 20, R = 1 I get Pr = 18! / (1! * 19!) = 1/19 = 0.0526
For T = 20, R= 10 I get Pr = 9!/(10! * 10!) = 1/(10 * 10!) = 2.76 x 10^-8

I am sorry that my answers differ from the previously quoted ones! It is of
course possible that the above is in error, and maybe[1] one of the real
mathematicians here will correct me in that case. Even if the above is wrong,
the method may be of interest. Or, of course, it may be right!

[1] As this is cam.misc, that is an absolute certainty, whether I am right or
wrong!
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

Scott Hemphill
science forum beginner

Joined: 09 Jun 2005
Posts: 21

Posted: Fri Jun 10, 2005 4:21 pm    Post subject: Re: Probability question

Martin Evans <Martin.Evans@arm.com> writes:

And what is the probability for 19 right answers out of 20? Hint: where

 Quote: [1] As this is cam.misc, that is an absolute certainty, whether I am right or wrong!

There are a few more newsgroups than just cam.misc.

Scott
--
Scott Hemphill hemphill@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

Posted: Fri Jun 10, 2005 4:29 pm    Post subject: Re: Probability question

 Quote: we get: Pr = (T-R-1)! / (R! * (T-R)!) For T = 20, R = 1 I get Pr = 18! / (1! * 19!) = 1/19 = 0.0526 For T = 20, R= 10 I get Pr = 9!/(10! * 10!) = 1/(10 * 10!) = 2.76 x 10^-8 I am sorry that my answers differ from the previously quoted ones! It is of course possible that the above is in error, and maybe[1] one of the real mathematicians here will correct me in that case. Even if the above is wrong, the method may be of interest. Or, of course, it may be right! - - -

I applaud your efforts -- but I took T=4, and got a total for all
probs R=0,1,2,3,4 of 6.25
Shomething wrong shurely!
(I may well have made a dumb mistake ..)
with best wishes
' - - -
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim i, j, iii, jjj, ii, jj As Integer
ReDim P(100, 100)
ReDim Q(100, 100)

Dim T, R, Rfact, TRfact, TR1fact As Integer
Dim tot, hold As Single
T = 4
TRfact = fact.fact(T - R)
TR1fact = fact.fact(T - R - 1)
tot = 0
For R = 0 To T
Rfact = fact.fact(R)
TRfact = fact.fact(T - R - 1)
'(T-R-1)! / (R! * (T-R)!)
hold = Rfact * TRfact
If hold > 0 Then tot = tot + TR1fact / hold
Next
MsgBox(tot)
end sub
' - - -
Module fact
Function fact(ByVal j As Integer) As Integer
Dim i As Integer
fact = 1
If j = 0 Then
fact = 0
Exit Function
End If
For i = 2 To j
fact = fact * i
Next
End Function
End Module
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

Posted: Fri Jun 10, 2005 5:56 pm    Post subject: Re: Probability question

(Correctedt code!)

-- but I took T=4, and got a total for all
 Quote: probs R=0,1,2,3,4 of 0.5833 Shomething wrong shurely! (I may well have made a dumb mistake ..) with best wishes ' - - - Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Button1.Click
Dim i, j, iii, jjj, ii, jj As Integer
ReDim P(100, 100)
ReDim Q(100, 100)

Dim T, R, Rfact, TRfact, TR1fact As Integer
Dim tot, hold As Single
T = 4
tot = 0
For R = 0 To T
TRfact = fact.fact(T - R)
TR1fact = fact.fact(T - R - 1)
Rfact = fact.fact(R)
'(T-R-1)! / (R! * (T-R)!)
hold = Rfact * TRfact
If hold > 0 Then tot = tot + TR1fact / hold
Next
MsgBox(tot)
 Quote: ' - - - Module fact Function fact(ByVal j As Integer) As Integer Dim i As Integer fact = 1 If j = 0 Then fact = 0 Exit Function End If For i = 2 To j fact = fact * i Next End Function End Module
Scott Hemphill
science forum beginner

Joined: 09 Jun 2005
Posts: 21

Posted: Fri Jun 10, 2005 7:31 pm    Post subject: Re: Probability question

Martin Evans <Martin.Evans@arm.com> writes:

 Quote: Then we have T-R columns left, each of which has the cell on the leading diagonal forbidden to us, as well as the rows already containing 'x's for right answers. The first column we add an 'x' to would thus have (T-R-1) valid cells available. So we would have No = (T-R-1)! using a similar argument as that for Nt.

This is where the error is. The first column will indeed have (T-R-1) valid
cells. However the second column and each additional column will will either
have (T-R-2) valid cells or (T-R-1) valid cells depending on whether the
corresponding row has already been picked.

For example, consider the case where T-R = 3, and just look at the 3x3 matrix
of containing the remaining rows and columns.

X . .
X . O = chosen, X = unavailable
O . X

Working column by column, if we pick the third row for the first column,
then there is only one choice for the second column.

X . .
O X .
. . X

If we instead pick the second row for the first column, then there are
two choices for the second column.

 Quote: The chance, Pr, of getting *exactly* R right answers in T tests is therefore Nr/Nt = (Nd * No) / Nt = (T! * (T-R-1)!) / (T! * (T-R)! * R!) Simplifying the above expression, we get: Pr = (T-R-1)! / (R! * (T-R)!)

This formula can't be right. What if T=R? You get a (-1)! term (which is
infinite).

If you have a correct formula, you should expect it to get the correct
results for easily verifiable simple cases:

T = 0
R = 0, Pr = 1

T = 1
R = 0, Pr = 0
R = 1, Pr = 1

T = 2
R = 0, Pr = 1/2
R = 1, Pr = 0
R = 2, Pr = 1/2

T = 3
R = 0, Pr = 1/3
R = 1, Pr = 1/2
R = 2, Pr = 0
R = 3, Pr = 1/6

T = nonnegative integer
R = T-1, Pr = 0
R = T, Pr = 1/T!

You should also expect that the sum of the probabilities for a given T
will be one!

Scott
--
Scott Hemphill hemphill@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
Alex Selby
science forum beginner

Joined: 30 May 2005
Posts: 10

Posted: Fri Jun 10, 2005 9:53 pm    Post subject: Re: Probability question

alan truelove wrote:
 Quote: From rec.org.mensa anyone got a slicker solution ?? ' - - - - - - - - - - - - On Thu, 9 Jun 2005 13:56:11 +0200, "Mark" Markiehatesspam@notelespam2.fr> wrote: "BruceS" wrote in message news:1118264621.238754.254340@f14g2000cwb.googlegroups.com... I wouldn't be at all offended if you reposted there and returned here with any answers. I try to avoid crossposting, especially to groups I don't follow. Here then is the question as I remember it: on consideration this may not be precisely on topic for sci.stat.math although I suppose that in general people who are up on stats are up on probability too. A student sits a test that has 20 questions; every question has precisely 1 matching answer. There are 20 answers, no duplication. The student answers every question with a different answer from the 20. What is the probability, of a student answering randomly, answering precisely 1 right? precisely 10 right? Mark ' - - - Getting 1 right: 0.3679 Getting 10 right: 0.01378 * 10^(-7) '- - - -

The probability of getting r right out of n is D(n-r)/(r!(n-r)!)
where D(k) = / 1 if k=0
\ the nearest integer to k!/e if k>0

This is well approximated by 1/(r!e) if r isn't too close to n.

---

Alex
alan truelove
science forum beginner

Joined: 09 Jun 2005
Posts: 8

 Posted: Sat Jun 11, 2005 5:23 am    Post subject: Re: Probability question Piled higher and even more deeper .. Develop iterative method for the following and then show a VB.Net code to implement it .. (I have a nice solution which goes on from my previous solutions, and uses a neat combinatorial method, but this space is too small to contain it) OK, it's June 11th, 2005, let's just see... ..- - - - - - - - - - - - - k groups of n objects each are presented; select one object from each group (a 'tuple') Given the first object, the (correct) other k-1 are unique. Repeat until all tuples have been selected. P(k,n,x) is prob(get x correct tuples)
Martin Evans
science forum beginner

Joined: 10 Jun 2005
Posts: 3

Posted: Mon Jun 13, 2005 11:09 am    Post subject: Re: Probability question

Scott Hemphill wrote:

 Quote: Pr = (T-R-1)! / (R! * (T-R)!) And what is the probability for 19 right answers out of 20? Hint: where does the 20th answer go?

For T = 20 and R = 19 we get Pr = (20 - 19 - 1)!/(19! * (20 - 1)!) = 0!/19! = 0

I think this is what we would expect - the probablity of getting exactly 19 questions
right would be zero, wouldn't it? PS - I don't need the hint, thanks! :-P

 Quote: [1] As this is cam.misc, that is an absolute certainty, whether I am right or wrong! :-) There are a few more newsgroups than just cam.misc.

Yes, of course there are.
Scott Hemphill
science forum beginner

Joined: 09 Jun 2005
Posts: 21

Posted: Mon Jun 13, 2005 12:39 pm    Post subject: Re: Probability question

Martin Evans <Martin.Evans@arm.com> writes:

 Quote: Scott Hemphill wrote: Pr = (T-R-1)! / (R! * (T-R)!) And what is the probability for 19 right answers out of 20? Hint: where does the 20th answer go? For T = 20 and R = 19 we get Pr = (20 - 19 - 1)!/(19! * (20 - 1)!) = 0!/19! = 0 I think this is what we would expect - the probablity of getting exactly 19 questions right would be zero, wouldn't it? PS - I don't need the hint, thanks!

No. 0! is not zero. It is one.

Scott
--
Scott Hemphill hemphill@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear
Scott Hemphill
science forum beginner

Joined: 09 Jun 2005
Posts: 21

Posted: Mon Jun 13, 2005 12:45 pm    Post subject: Re: Probability question

Scott Hemphill <hemphill@hemphills.net> writes:

 Quote: Martin Evans writes: Scott Hemphill wrote: Pr = (T-R-1)! / (R! * (T-R)!) And what is the probability for 19 right answers out of 20? Hint: where does the 20th answer go? For T = 20 and R = 19 we get Pr = (20 - 19 - 1)!/(19! * (20 - 1)!) = 0!/19! = 0 I think this is what we would expect - the probablity of getting exactly 19 questions right would be zero, wouldn't it? PS - I don't need the hint, thanks! :-P No. 0! is not zero. It is one.

I mean, yes the probability is zero. But, no your formula doesn't produce
that result.

Scott
--
Scott Hemphill hemphill@alumni.caltech.edu
"This isn't flying. This is falling, with style." -- Buzz Lightyear

 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 Page 6 of 8 [110 Posts] Goto page:  Previous  1, 2, 3, 4, 5, 6, 7, 8 Next View previous topic :: View next topic
 The time now is Thu Jan 17, 2019 12:38 pm | All times are GMT
 Jump to: Select a forum-------------------Forum index|___Science and Technology    |___Math    |   |___Research    |   |___num-analysis    |   |___Symbolic    |   |___Combinatorics    |   |___Probability    |   |   |___Prediction    |   |       |   |___Undergraduate    |   |___Recreational    |       |___Physics    |   |___Research    |   |___New Theories    |   |___Acoustics    |   |___Electromagnetics    |   |___Strings    |   |___Particle    |   |___Fusion    |   |___Relativity    |       |___Chem    |   |___Analytical    |   |___Electrochem    |   |   |___Battery    |   |       |   |___Coatings    |       |___Engineering        |___Control        |___Mechanics        |___Chemical

 Topic Author Forum Replies Last Post Similar Topics about uni. continuous proof bill1158 Math 1 Tue Jul 18, 2006 10:30 pm Distribution of Goldbach pairs as even integers n increases stargene@sbcglobal.net Math 1 Mon Jul 17, 2006 5:02 am (humor) Another hand-waving incredibly simple proof of FLT DGoncz@aol.com Math 0 Fri Jul 14, 2006 7:50 pm Odd Squares, 8 (2^3), and the Sum of the First n Positive... rer Math 1 Thu Jul 13, 2006 1:58 am JSH: Way too interesting jstevh@msn.com Math 22 Thu Jul 13, 2006 1:15 am