# Statistics Problem



## EE2006 (Mar 13, 2007)

I have a little statistics problem I want to figure out, and I was hoping some people here may be able to help. After seeing all the good responses to the Birthday Problem thread, I figure someone might be able to help me.


You have 5 teams, broken up as follows:

Team A - 3 males, 3 females
Team B - 3 males, 3 females
Team C - 3 males, 3 females
Team D - 3 males, 3 females
Team E - 1 male, 1 females


There will be 4 groups formed at random from these teams:

Group A - 6 males
Group B - 7 males
Group C - 6 females
Group D - 7 females


I have two questions based on this:

(1) What is the likelihood of all 3 males (or all 3 females) from one team all ending up in the same group?

ex. All 3 males from Team A end up in Group A

(2) What is the likelihood that all 3 males from one team will end up in one group AND all 3 females from one team will end up in one group, while no other team placing either 3 males or 3 females in one group?

ex. All 3 males from Team A end up in Group A
     All 3 females from Team A end up in Group C
     All other teams are split up


I hope I worded the second question well, if you need any clarification just let me know. Thanks in advance for any answer you can give.


----------



## Joe4 (Mar 13, 2007)

You wouldn't be asking us to do your homework for you now, would you?


----------



## EE2006 (Mar 13, 2007)

> You wouldn't be asking us to do your homework for you now, would you?



Not unless they have started handing out homework to people who are no longer in school. 

This question comes from a real-life observation. Scheduling for the tournament was done by Team A, and they were the only ones who were lucky enough not to be split up. I thought it was interesting, and just wanted to see the numbers on it.


----------



## Joe4 (Mar 13, 2007)

I was a Mathematics and Economics major in college, and I hated doing statistics then (I always preferred Calculus)!   

I can't imagine doing it for fun when you don't have to, but I'm sure a few people will take up your challenge.


----------



## EE2006 (Mar 13, 2007)

Being an Engineer, I also have a natural leaning towards Calculus over Statistics. Having said that, as a huge sports fan and a born numbers guy, I do appreciate statistics.

My problem is that I usually don't know the correct approach. Once Eric got the ball rolling in the Birthday Problem thread, I could extend the idea in many different directions. It's getting that first idea going that usually stumps me.


----------



## Andrew Fergus (Mar 14, 2007)

Hi

Here's my take on your question.  What are the chances of 3 males from the same team ending up in the same group?

Once you have your first male from a team in a group (lets say of 6) it comes down to the probability of selecting the other two guys from that team in one of the remaining available slots in that group.

Assuming the groups are divided purely into males and females, the chances of selecting a 2nd male from the first team in the same group (of 6) is 1/12 + 1/11 + 1/10 + 1/9 + 1/8 which adds to about a 51% probability.  The chances of selecting a 3rd male from the same team, after a 2nd person has been added to the same group, is 1/11 + 1/10 + 1/9 + 1/8 which is about a 43% probability.  Multiplying the 2 together gives a probability of about 22% of all 3 guys from the same team ending up in the same group (of 6).

The probablity would be higher for 3 guys ending up in the same group of 7 - if you started with that one first.  I suspect the probablities would also be different if each group selected a person in turn, instead of picking 6 guys for Group A and then the rest automatically go into Group B (this later method is the method I assumed in my calculation).

Hopefully I have my maths right - if not I'm happy to be guided as to where I went wrong.

Cheers, Andrew


----------



## Joe4 (Mar 14, 2007)

> Being an Engineer, I also have a natural leaning towards Calculus over Statistics. Having said that, as a huge sports fan and a born numbers guy, I do appreciate statistics.


Well, sports stats, that's a whole different ball game than probability!  I love sports stats too.  I was calculating my batting average and ERA myself back in the third grade.  I used to buy baseball, football, and hockey cards for the numbers on the back, not the pictures on the front... :wink:


----------



## Greg Truby (Mar 14, 2007)

> I used to buy baseball, football, and hockey cards for the numbers on the back, not the pictures on the front... :wink:
> ~jm14



Oh, you mean the side with the picture was the _front_?!


----------



## Richard Schollar (Mar 14, 2007)

> > I used to buy baseball, football, and hockey cards for the numbers on the back, not the pictures on the front... :wink:
> > ~jm14
> 
> 
> ...



They had _pictures_ on the Front?!?!??!


----------



## Lewiy (Mar 14, 2007)

Probability of an event = (Number of ways the event can occur) / (Total number of possible combinations)

Now the question is: How many combinations of different males on different teams can there be?  My brain stops working here.


----------



## iknowu99 (Mar 14, 2007)

Deal with one gender first, due to the parallels and independence.

1) 

The total: AAA can fit into 13 >> 13choose3 ways or 13C3

total ways AAA can go into a 'six group' is 6choose3 or 6C3=20

These guys can also go to Group B.  There they can fit 7C3 or 35 different ways.

multiply that by 4 since A or B or C or D can be grouped
4 * (6C3 + 7C3) / 13C3

this is when team members from at least one team are joined again on a group


----------



## iknowu99 (Mar 14, 2007)

2)

When you capitalize AND in math it refers to independent events and the two events must be multiplied

X=(7C3+6C3)/13C3

X squared is the case when two teams, for example AAA and BBB are fit inside the 13 slots. both teams are grouped.


4X-(X^2 + X^3 + X^4) square this for both males and females = .5238413672


----------



## iknowu99 (Mar 14, 2007)

i learned i made a mistake, the following is done with vba and iterationsBook1.xlsABCDEFGHIJ1A2BADBDCB3C4D5E6AEADDCCB7B8C9Diterations10A14540311B12C13D14no teams or groups685500.471448151 team to group455960.313584162 teams to group or groups276840.190395173 teams to group or groups30350.020873184 teams to group or groops5380.00371920Sheet2


```
Option Explicit

Sub CombinationsCHECK()

Dim i%
Dim x%
Dim iterations As Double
Dim string6word$
Dim string6$, string7word$

Dim PatternMatch6%, PatternMatch7%

'Application.ScreenUpdating = False


For iterations = 1 To 1000000
        
    Range("A1:A13").Font.ColorIndex = 0


'6
    For x = 1 To 6
gotohere:
    i = Int((13) * Rnd + 1)
    
    If Cells(i, 1).Font.ColorIndex<> 3 Then
    Cells(2, 2 + x) = Cells(i, 1)
    Cells(i, 1).Font.ColorIndex = 3
    Else: GoTo gotohere
    End If
    
    Next x



For x = 1 To 6
string6word = string6word & Cells(2, 2 + x)
Next x

If Len(string6word) - Len(Replace(string6word, "A", "")) = 3 Then PatternMatch6 = 1 + PatternMatch6
If Len(string6word) - Len(Replace(string6word, "B", "")) = 3 Then PatternMatch6 = 1 + PatternMatch6
If Len(string6word) - Len(Replace(string6word, "C", "")) = 3 Then PatternMatch6 = 1 + PatternMatch6
If Len(string6word) - Len(Replace(string6word, "D", "")) = 3 Then PatternMatch6 = 1 + PatternMatch6

'Cells(15, 5) = Cells(15, 5) + 1





'7
    For x = 1 To 7
gotohere2:
    i = Int((13) * Rnd + 1)
    
    If Cells(i, 1).Font.ColorIndex<> 3 Then
    Cells(6, 2 + x) = Cells(i, 1)
    Cells(i, 1).Font.ColorIndex = 3
    Else: GoTo gotohere2
    End If
    
    Next x


For x = 1 To 7
string7word = string7word & Cells(6, 2 + x)
Next x

If Len(string7word) - Len(Replace(string7word, "A", "")) = 3 Then PatternMatch7 = 1 + PatternMatch7
If Len(string7word) - Len(Replace(string7word, "B", "")) = 3 Then PatternMatch7 = 1 + PatternMatch7
If Len(string7word) - Len(Replace(string7word, "C", "")) = 3 Then PatternMatch7 = 1 + PatternMatch7
If Len(string7word) - Len(Replace(string7word, "D", "")) = 3 Then PatternMatch7 = 1 + PatternMatch7

'Cells(15, 6) = Cells(15, 6) + 1



If PatternMatch7 + PatternMatch6 = 0 Then Cells(14, 6) = Cells(14, 6) + 1

If PatternMatch7 + PatternMatch6 = 1 Then Cells(15, 6) = Cells(15, 6) + 1

If PatternMatch7 + PatternMatch6 = 2 Then Cells(16, 6) = Cells(16, 6) + 1

If PatternMatch7 + PatternMatch6 = 3 Then Cells(17, 6) = Cells(17, 6) + 1

If PatternMatch7 + PatternMatch6 = 4 Then Cells(18, 6) = Cells(18, 6) + 1

If PatternMatch7 + PatternMatch6 = 5 Then
Cells(19, 6) = Cells(19, 6) + 1
End If




Cells(10, 10) = iterations



PatternMatch6 = 0
PatternMatch7 = 0
string6word = ""
string7word = ""
    Range("A1:A13").Font.ColorIndex = 0
Next iterations


End Sub
```


----------



## Bob Rooney (Mar 16, 2007)

> I have a little statistics problem I want to figure out, and I was hoping some people here may be able to help. After seeing all the good responses to the Birthday Problem thread, I figure someone might be able to help me.
> 
> 
> You have 5 teams, broken up as follows:
> ...



For the first question only at this time.  I hope I understood it to give you the correct answer.

Probability of all from one team together in the regrouping...

Team of 6 males/females:

COMBIN(3,3)*COMBIN(10,3) / COMBIN(13,6) = 120/1716 = .06993

Team of 7 males/females:

COMBIN(3,3)*COMBIN(10,4) / COMBIN(13,7) = 216/1716 = .12238

However, each of these must be multiplied by 4 to get the total possibility for ANY team to have all their members/gender selected for the regrouped team.

I have ignored the Team E option, because the all members to one group condition clearly applies.

PLEASE NOTE:  Excel has a built-in function (Analysis ToolPak?) that calculates this directly
HYPGEOMDIST(...)

I will look at this in more detail and also the second part.


----------



## Bob Rooney (Mar 16, 2007)

I am getting a different answer.

Probability of a regrouped team having all members from an initial group equals 1 - Prob members are split.

For the members to be split, that means that each initial team has either 1 or 2 members chosen (cannot be 0 or 3), except for Team E, of course.

10 possible scenarios can occur, each equally likely.

P(no group intact) = 47.2% -->  P(at least one group intact) = 52.8%.Book1ABCDEFGH1Option with no team having all members on a reselected team of 6:2TeamABCDE3Total Per Team3333145I111214.72%6I112114.72%7III121114.72%8IV211114.72%9V112204.72%10VI122104.72%11VII221104.72%12VIII211204.72%13IX121204.72%14X212104.72%151647.20%Sheet1


----------



## Bob Rooney (Mar 16, 2007)

OOPS.  The second table did not come through.  The probabilities with 7 equal the probabilities with 6 members to a team.

Somewhere my mathematics is incorrect.  Will try to determine where it is wrong.


----------



## iknowu99 (Mar 16, 2007)

Hi Bob, I agree with your 47.2 calculation. From how i understand the problem the simulation i ran is close to the answer yet i can not prove this with math; at least not yet 

what i was tryin earlier: 6choose3 is when 3 A's try to make it to the 6 group, there are 20 ways they can fit to the 6 group; to the 7 group 7c3, so 35 ways. When 3 A's try to make it to the other side they have 13c3 ways to do this. 

On a general note multiplying events means these events will happen at the same time. So my suggested answers 1) ~31.3584%. 2) ~9.8335%


----------



## Bob Rooney (Mar 16, 2007)

This has to have an exact answer that is more straightforward than this...

In A1:E1, type the A, B, C, D, E category headings.
In A2:E2, type 3,3,3,3,1

Preselect A3:E86, go to the formula bar and type in 
=Numer(6,A2,B2,C2,D2,E2)

6 is the total selected per the new group.  

Confirm with Ctrl-Shift-Enter to array enter results.

The Numer UDF is


```
Function Numer(TotSel As Long, A As Long, B As Long, C As Long, D As Long, E As Long)

Dim v As Long, w As Long, x As Long, y As Long, z As Long
Dim Cnt As Long

Dim arrList
For v = 0 To A
    For w = 0 To B
        For x = 0 To C
            For y = 0 To D
                For z = 0 To E
                    If v + w + x + y + z = TotSel Then
                        Cnt = Cnt + 1
                        If Cnt = 1 Then
                            ReDim arrList(1 To 5, 1 To Cnt) As Long
                        Else
                            ReDim Preserve arrList(1 To 5, 1 To Cnt) As Long
                        End If
                        arrList(1, Cnt) = v
                        arrList(2, Cnt) = w
                        arrList(3, Cnt) = x
                        arrList(4, Cnt) = y
                        arrList(5, Cnt) = z
                    End If
                Next z
            Next y
        Next x
    Next w
Next v

Numer = Application.Transpose(arrList)
End Function
```

The Numer UDF exhausts all legal possible successful outcomes and lists them on the worksheet.

In F3, array-enter the following formula:
=PRODUCT(COMBIN($A$2:$E$2,A3:E3))

Copy down to F86.

In G3, enter 
=IF(OR(COUNTIF(A3:D3,3)<>0,COUNTIF(A3:D3,0)<>0),1,0)
and copy down to G86.  No need to check column E, as that is the single member E group.

In H3, enter the following formula  =SUMPRODUCT(F3:F86,G3:G86)  

I got 906.  This is the numerator to the equation.  The denominator equals =COMBIN(13,6) = 1716.

The probability of 3 members from the same team land in the group of 6 or 7 is 906/1716 or 52.8%.

We only need to use the new group of 6 members.  Testing if 3 members in the new group occur AND testing if zero members occur in the new group -- indicating all 3 went to the new group with 7 elements.

This is the same as earlier, 1 - P(1 or 2).

Still do not understand fully why the HYPGEOMDIST option does not work.


----------



## pgc01 (Mar 17, 2007)

Hi

This is a problem of Combinatorics like the ones I (vaguely) remember doing at school.

I solved it analytically (as far as I can remember how one did it). I got the same result as Bob.Book1.xlsABCDEF12Totalnumberofpossiblegroupsof6people(Combin(13,6):171634Thereare5possiblecases:5Total6Case1NoneoftheteamsA,B,CandDhaveallitsmemberstogetherineitherG6orG78107Case2Thereis1andonly1teamA,B,CorDthathasallitsmemberstogetherineitherG6orG75408Case3Thereare2andonly2oftheteamsA,B,CorDthathaveallitsmemberstogetherinG6orG73249Case4Thereare3andonly3oftheteamsA,B,CorDthathaveallitsmemberstogetherinG6orG73610Case5Allthe4teamsA,B,CandDhaveallitsmemberstogetherinG6orG7611GUI

(1) What is the likelihood of all 3 males (or all 3 females) from one team all ending up in the same group?

Likelihood of all 3 males from one team all ending up in the same group or likelihood of all 3 females from one team all ending up in the same group:

(Case2 + Case 3 + Case 4 + Case 5) / Total = 906 / 1712 = 52.8 %

or

(Total - Case 1) / Total = 52.8%

Likelihood of all 3 males (or all 3 females) from one team all ending up in the same group:

1-( Case 1 / Total) * ( Case 1 / Total) = 77.7%

(2) What is the likelihood that all 3 males from one team will end up in one group AND all 3 females from one team will end up in one group, while no other team placing either 3 males or 3 females in one group? 

Since the events are independent

(Case 2 / Total) * (Case 2 / Total) = 9.9 %

Cheers
PGC

P. S. Analytical resolution:

- I will call the final group of 6 people G6 and the final group of seven people G7.
- I will only use the group of 6 people to do the calculations, since the group of 7 people adds no information.
- I will use the numbers 1, 2, 3 and 4 to represent an element of one of the teams A, B, C D and the letter E to represent the element in group E

Case 1 - None of the teams A, B, C and D have all its members together in either G6 or G7

There are 2 possible configurations of G6

112234: Combin(4,2)*3*3*3*3=486
11234E: 4*3*3*3*3=324

Total for Case 1: 486+324 = 810

Case 2 - There is 1 and only 1 team A, B, C or D that has all its members together in either G6 or G7

There are 3 possible configurations of G6

111234: 4*3*3*3=108
112233: Combin(4,3)*3*3*3=108
11223E: Combin(4,2)*3*3*2*3=324

Total for Case 2: 108+108+324 = 540

Case 3 - There are 2 and only 2 of the teams A, B, C or D that have all its members together in G6 or G7

There are 2 possible configurations of G6

111223: 4*3*3*2*3=216
11123E: 4*Combin(3,2)*3*3=108

Total for Case 3: 216+108 = 324

Case 4 - There are 3 and only 3 of the teams A, B, C or D that have all its members together in G6 or G7

There is 1 possible configuration of G6

11122E: 4*3*3=36

Total for Case 4: 36

Case 5 - All the 4 teams A, B, C and D have all its members together in G6 or G7

There is 1 possible configuration of G6

111222: Combin(4,2)=6

Total for Case 5: 6


----------



## pgc01 (Mar 17, 2007)

Curious.

I compared my values with the ones in the table that iknowu99 posted and they are very (very) similar but not exactly equal.

I wonder why such small differences?Book1.xlsABCDEFGH12iknowu99PGC34Case1NoneoftheteamsA,B,CandDhaveallitsmemberstogetherineitherG6orG70.4714480.4720285Case2Thereis1andonly1teamA,B,CorDthathasallitsmemberstogetherineitherG6orG70.3135840.3146856Case3Thereare2andonly2oftheteamsA,B,CorDthathaveallitsmemberstogetherinG6orG70.1903950.1888117Case4Thereare3andonly3oftheteamsA,B,CorDthathaveallitsmemberstogetherinG6orG70.0208730.0209798Case5Allthe4teamsA,B,CandDhaveallitsmemberstogetherinG6orG70.0037000.0034979GUI


----------



## iknowu99 (Mar 18, 2007)

pgc, i agree with your solution. Combinations are def the way to go, i was trying for a while to get to these results. While in excel i created a simulation of the problem and after enough iterations the solutions should converge. 

I hope you try my code, all you need is to 
-enter ABCDEABCDABCD in A1 through A13
-enter VBA code into a module and launch
-watch for xmas lights

fun challenge, good day and until the next one


----------



## Bob Rooney (Mar 19, 2007)

A few comments about the second problem...

1.  I agree with the 9.9% answer (540/1716)^2

2.  Pairing the matches is interesting.  I originally read the second part of the problem to mean that. for example, Team A's Males are assigned to a single group and no other Male team is transferred intact AND Team A's Females are assigned to a single group and no other Female team's members are reassigned to the same group.  That is, a full original team is transferred intact while all others are split.

Let 
M6 = Male group of 6 members
M7 = Male group of 7 members
F6 = Female group of 6 members
F7 = Female group of 7 members

Individually, we have the following
            Team of 6         Team of 7
A               27                   108
B               27                   108
C               27                   108
D               27                   108
Total         108                   432

as noted by others.  A team is 4 times more likely to transfer intact to the group of 7 than the group of 6.  

There are 291,600 (540^2) total intact teams, broken down as 

M6F6  = 729 x 4  = 2916
M6F7  = 2916 x 4 = 11664
M7F6  = 2916 x 4 = 11664
M7F7  = 11664 x 4 = 46656

Total matched pairs (only a single original team have both M anf F members transfer intact).  = 72900

Total non-matched pairs (only one team each transfers, but not from the same original grouping, e.g. A males and C females) = 218700

M6F6  = 2187 x 4  = 8748
M6F7  = 8748 x 4 = 34992
M7F6  = 8748 x 4 = 34992
M7F7  = 34992 x 4 = 139968

Following probability rules of independent events, note that combined M and F transfers are 16x more likely to transfer to the team of 7 rather than to the team of 6.

Looking at the combinations, it is easy to see, but my first intuition would have been a much smaller difference.  Perhaps someone can devise a parlor trick to take advantage of this fact.


----------

