[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

2030.0. "Proabability: Bag of balls, three colors." by FORTY2::BOYES (My karma ran over my dogma) Thu Feb 22 1996 09:24

I'm sure I could have done this in my head while in college, but now that
it actually matters (in as much as the card game related application I have in
mind matters), I am stumped...


I have a bag of balls.
19 Black
4  Red
37 White

I pull out ten without replacing any. What is the probability I will have
drawn at least one Red and at least three Black?


Please show your working so I can extrapolate to a general formula in my
own time!

+Mark+
T.RTitleUserPersonal
Name
DateLines
2030.1suggested approachFLOYD::YODERMFYThu Feb 22 1996 10:023
If you *don't* have at least 1 red and 3 black, you must have 0 red and either
0, 1, or 2 black.  Perhaps it's easy to treat those 3 cases separately, add the
results, and subtract from C(60,10).
2030.2AUSSIE::GARSONachtentachtig kacheltjesWed Feb 28 1996 03:507
    re .1
    
    Subtracting from C(60,10) implies that the 60 objects are distinct.
    This is OK as long as you also take this approach when you count the
    number of ways to get 0, 1 or 2 black.
    
    Either way this gets pretty hairy in the general case.
2030.3HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Wed Feb 28 1996 10:5247
19 black, 4 red, 37 white, I pull out 10.  What is probablility that
I have at least 1 red and at least 3 black ?

I would approach it this way:


I would look at all the possibilities of what I might have pulled.

At least 1 red means 1 red or 2 red or 3 red or 4 red.  So I would add up
how many ways I can have exactly 1 red plus the ways I can have exactly 2 reds
plus the ways I can have exactly 3 plus exactly 4.

But it's not quite as simple, since I want at least 3 black too.

So, I want at least 1 r and at least 3 b.  The possibilities of interest are
these

	exactly 1r + 3b
	exactly 2r + 3b
	exactly 3r + 3b
	exactly 4r + 3b
	exactly 1r + 4b
	exactly 2r + 4b
	...
	exactly 4r + 6b

Each of these possibilities are distinct, that is, they don't overlap.  So
We can ADD their probabilities.

	p(1r+3b) = ???

p(1r+3b) is a bit challenging in itself.  We need to know how many ways we
can pick exactly 1 r and 3 b.  Agan, I'd divide this into distinct cases so
we will be allowed to add their probabilities.  The 1 r can be in 10 different
positions, and for each of those 10, the 3 b's can be in (9,3) different
arrangements.

I think I could really solve this if I put my mind to it.  However, my
general suspicion is that your original problem as posed is MUCH HARDER than
the actual problems you were given in school in the past.

My specific surface-scratching solution started up above really all amounts
to listing EVERY possible way to pick the 10 balls, and use that as the bottom
of a fraction whose top consists of counting the cases that qualify as "at
least 1 red and at least 3 black".  This fraction is your answer.

/Eric
2030.4a small C program will helpGVAADG::DUBEZero is not not not zero, or is it?Wed Feb 28 1996 13:5489
>>	p(1r+3b) = ???

this is C(4,1) * C(19,3) * C(37,6) / C(60,10)
                            ^           ^
         ^        ^         |           |
         |        |         6 whites   Universe of all combinations
       1 red     3 blacks   over 37           
       over      over 19 poss
       4 possibilities

In general, the proba to have "r read + b black + w white" is:
       P(r, b, w) = C (4,r) * C (19,b) * C(37,w) / C(60,10)

So, to have "at least one red" and "at least 3 blacks", we get
       
           r=4  b=10-r
       P = SUM   SUM    C(4,r) * C(19,b) * C(37,10-r-b) / C(60,10)
           r=1  b=3

I got  P = 0.33138659, using this following C program
  {for compiling : Extract it as balls.c
		   CC balls.c
                   define lnk$library sys$library:vaxcrtl.olb
		   Link balls
		   Run Balls
  }

Friendly, 

##### Remy #####

ps: and now, here is the C program:



#include <stdio.h>
#include <math.h>

const	tot_red	    = 4;
        tot_black   = 19;
	tot_white   = 37;

        tot_withdraw= 10; /* want to pull out 10 of them */
	min_red	    = 1;  /* want at least 1 red         */
	min_black   = 3;  /* want at least 3 blacks	 */

/*******************************************************************************
    computes here the factorielle of n, i.e. n*(n-1)*...*1; with fact(0) = 1   *
*******************************************************************************/

double fact (int n)

   {double result = 1.0;

    for (;n>0;n--) result *= n;
    return result;
   }

/*******************************************************************************
 computes now number of combinations of n objects, selected by set of p elements
*******************************************************************************/

double comb (int n, int p)

   {double result = 1.0;

    for (; p>0; p--, n--) result = result * n / p;
    return result;    
   }

/*******************************************************************************
                             MAIN COMPUTATION
*******************************************************************************/

main ()

   {int r, b, w;
    double proba, cumulated_proba =0;
    double univers = comb(tot_red+tot_black+tot_white, tot_withdraw);

    
    for (r=min_red;   r<=tot_red   && r  <= tot_withdraw; r++)
    for (b=min_black; b<=tot_black && b+r<= tot_withdraw; b++)
      {w = tot_withdraw-b-r;
       proba = comb(tot_red,r)*comb(tot_black,b)*comb(tot_white,w) / univers;
       cumulated_proba += proba;
       printf("%2d %2d %2d %10.8f %10.8f\n", r, b, w, proba, cumulated_proba);
      }
   }
2030.5CSC32::D_DERAMODan D&#039;Eramo, Customer Support CenterWed Feb 28 1996 19:546
        The previous replies give 24,984,569,384 of the 75,394,027,566
        = C(60,10) possible combinations for a probability of
        24984569384/75394027566 = 38,675,804/116,709,021 = approx.
        0.331386585789285302975851369706888.
        
        Dan
2030.6Special thanks to RemyFORTY2::BOYESMy karma ran over my dogmaThu Feb 29 1996 06:046
Dan et al,

I was expecting there to be a simple algorithm, but a prgram to thrash it
out is great! Thanks a lot!

+Mark+ 
2030.7CSC32::D_DERAMODan D&#039;Eramo, Customer Support CenterThu Feb 29 1996 10:2222
>I was expecting there to be a simple algorithm, but a prgram to thrash it
>out is great! Thanks a lot!
        
        The simple algorithm is there in reply .4 as well.
        There are C(60,10) ways to select 10 of 4+19+37 = 60
        distinguishable balls without replacement.  The number of
        those ways with r red, b black, and w white is implicit in the
        formula from .4, which gave the probability as that number
        ways divided by C(60,10) ...
        
>In general, the proba to have "r read + b black + w white" is:
>       P(r, b, w) = C (4,r) * C (19,b) * C(37,w) / C(60,10)

        Just add up the total count or the probabilities for each
        (r,b,w) combination that meets your criteria.  That's the
        simple algorithm:
        
        	number_ways = sum for each acceptable (r,b,w) of
        		C(4,r) * C(19,b) * C(37,w)
        	probability = number_ways / C(60,10)
        
        Dan
2030.8FORTY2::BOYESMy karma ran over my dogmaThu Feb 29 1996 11:3714
>        simple algorithm:
>        
>        	number_ways = sum for each acceptable (r,b,w) of
>        		C(4,r) * C(19,b) * C(37,w)
>        	probability = number_ways / C(60,10)

Yep I grasped that, and thats my idea of a simple algorithm too, but what I
expected was there to be a simple formula that didn't involve the 'each
acceptable' clause: whilst I'm happy with it, I expected there to be fewer
implicit 'sigmas' in the solution.

Thanks again,

+Mark+