All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Bean coloring (Posted on 2015-07-13) Difficulty: 4 of 5
Start with a bag containing 5 white beans. Randomly draw one at a time employing the following rule:

If the bean is white, color it black and put it back in the bag;
If the bean is black, keep it out.

What is the probability that at some point there will be a single white bean in the bag?

Generalize to start with N beans.
Does the probability converge, and if so, to what value?

No Solution Yet Submitted by Jer    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Further exact values using UBASIC | Comment 5 of 11 |
(In reply to computer aided solution by Charlie)

If there are n beans to start with and b beans are left after d draws, then, since n-b beans have disappeared, 2*(n-b) of the d draws have been used to disappear beans, the number of black beans left is d - 2*(n-b) and the number of white beans is then b - d + 2*(n-b) = 2*n - b - d

This allows us to use a 1-dimensional array of number of beans remaining, and still know how many are white and how many are black and any stage, d, of the procedure.  That in turn allows use of UBASIC for larger values of n, with its greater precision and its storage of exact rational numbers, despite its limitation of total elements to 200. It reports the probability that only 1 bean remains after 2*(n-1) draws, rather than 2, as one bean would be white, but 2 beans would be black.

In the formula for black beads in the program, D-1 rather than D is used, as the draw being calculated has not taken place prior to this draw.

    4   kill "beancolr.txt"
    5   open "beancolr.txt" for output as #2
   10   dim Oldb(90),Newb(90)
   20   for N=2 to 30
   30    erase Oldb()
   40    dim Oldb(N)
   50    Oldb(N)=1
   60    for D=1 to 2*(N-1)
   70      erase Newb()
   80      dim Newb(N)
   90       for B=2 to N
  100        if Oldb(B)>0 then
  110        :Black=D-1-2*(N-B):White=B-Black
  120        :Newb(B-1)=Newb(B-1)+Oldb(B)*Black//B
  130        :Newb(B)=Newb(B)+Oldb(B)*White//B
  140        :endif
  150       next B
  160       for B=1 to N
  170         Oldb(B)=Newb(B)
  180       next B
  190    next D
  200    print N,Newb(1),Newb(1)/1
  205    print #2,N,Newb(1),Newb(1)/1
  210   next N
  220   close #2

I've modified the output to replace double-/ with single /, and truncated the results (cutting off at n=19) so the large numbers would not greatly expand the window allotted. For the larger ones, I've separated the numerator and denominator onto two lines.


 2   1/2   0.5 
 3   7/18   0.3888888888888888888 
 4   97/288   0.3368055555555555555 
 5   54997/180000   0.3055388888888888888 
 6   460463/1620000   0.2842364197530864196 
 7   51185279267/190591380000   0.2685603056497098661 
 8   200170674968477/780662292480000   0.2564113534068320931 
 9   11369422537341929933/46097327708651520000   0.2466395147501819988 
 10   6873027837417268175729/28810829817907200000000   0.2385570940114115901 
 11   173163272842349985846536059219169/747278726094210559615027200000000   0.2317251472518421861 
 12   168772133656672827075008567368139/747278726094210559615027200000000   0.2258489741020614426 
 13   3842815959898463365301025948437541787295761139
      /17410163370762081276553474535120146483200000000   0.2207225675062838212 
 14   442833976487751453451845289533115618663180920930551
      /2048288310406788100105239725582350113601996800000000   0.2161970920977452871 
 15   271605621773967287861163059327877888253955472822789551
      /1280180194004242562565774828488968821001248000000000000   0.2121620245696967696 
 16   1146585683227688521430368531418768743587440561958751522161688661
      /5498332066235157091471236737260130182964038135185408000000000000   0.2085333641939861734 
 17   54914670162209509582192304011109671718184598872345633534579943119292785699166225061
      /267555391671200852451892607513749958318859975038049807576997165686325248000000000000  
      0.2052459859590279339 
 18   258819282870746576472902196651366139225248527085967063366380554634931856876858842095501029
      /1279709144146211870050976333067433124390399375947766050096742556565557385101312000000000000 
      0.2022485219041112374 
 19   26583896812182990412714688743262439366381795231421715900029755514387245409789265482456656860178254671498968825629
      /133252722331952794500479894206857954240573271518729997224070375088768946767085399118394931282960187392000000000000 
      0.1994998402055791471 

Edited on July 14, 2015, 10:52 am
  Posted by Charlie on 2015-07-14 10:42:50

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information