Solved

Probability question

Posted on 2006-07-08
12
384 Views
Last Modified: 2013-11-13
Suppose there is a bottle of pills, if a whole pill is drawn, it is bitten in half then one of the halves is placed back in the bottle. If a half is drawn, then it is taken and it disappears from the bottle. And every pill, half or whole, is equally likely to be picked.

How could I make a function P(n) that tells me the probability of drawing a half after n trials?


Thanks
0
Comment
Question by:InteractiveMind
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 37

Assisted Solution

by:Harisha M G
Harisha M G earned 20 total points
ID: 17066109
Hi,

Assume there are N pills

Probability of drawing a half pill "after" 0 trials = 0 (since all are whole pills)

Probability of drawing a half pill "after" 1 trials = 1/N (only one is half pill and others are whole pills)

Now, if half pill was drawn in the second trial,
Probability of drawing a half pill "after" 2 trials = 0
or, if a full pill was drawn in the second trial,
Probability of drawing a half pill "after" 2 trials = 2/N
So, In general,
Probability of drawing a half pill "after" 2 trials = 1/N*0 + (1-1/N)*2/N = 2(N-1)/N²

Continuing with this is somewhat difficult...

---
Harish
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 17066119
Hmm, I see what you mean.

Perhaps there's some sort of recursive algorithm which could be used?
..As it doesn't actually *have* to be a math function; an algorithm is fine..

:\

Any ideas?

Cheers
0
 
LVL 18

Assisted Solution

by:JR2003
JR2003 earned 30 total points
ID: 17066392
Have a look at example 14 in the following link:

http://www.stat.yale.edu/~pollard/stat241/notes2005/all2000notes.pdf
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 17066493
Rob, not related to probability, but it gives the states which are traversed..

This is an Excel Macro..

Sub States()
    Sheets(1).Activate
    Sheets(1).Cells.Clear
    N = InputBox("Enter N")
    Dim i As Double, j As Double, k As Double
    For i = N To 0 Step -0.5
        m = 0
        For j = Int(i) To 0 Step -1
            For k = 0 To 2 * i
                If ((j + k * 0.5 = i) And (j + k <= N)) Then
                    m = m + 1
                    Cells((N - i) * 2 + 1, m) = j & " " & k
                End If
            Next
        Next
    Next
End Sub
0
 
LVL 14

Expert Comment

by:ECNSSMT
ID: 17066623
err unless you've assume that the 1/2 bitten pill was placed back in the bottle in a random manner (placed back and the bottle was shaken); it can fairly be assumed that the pill will be on top or close to the top of the bottle.  

This implies that the 1/2 bitten pill has a better chance of being picked than the normal 1 in N chances.  The pills towards the top of the bottle has a better chance of being pick by the pill popping community than the ones in the bottom of the bottle.

Unless someone has a hand small enough to reach in to the bottle to permit the equal choosing of all pills per the length of the bottle. Or the pills are placed in a big enough bottle where all the pills have an equal chance of being picked....

Regards,  

0
 
LVL 27

Expert Comment

by:d-glitch
ID: 17066729
This is a discrete problem that would probably benefit from an analog solution.

Note that the system will tend to regulate itself so that the number of whole pills and half pills is the same.
    If there are more whole pills, they are more likely to get chosen and broken.
    if there are more half pills, they are more likely to get chosen and removed.

So I would expect something like

             1  -  exp(-kn/N)
P(n)  =   ------------------
                     2

I would recommend a few simulations to find the value of k.  And I wouldn't be surprised if  k=1  for N > n >> 0.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 37

Expert Comment

by:Harisha M G
ID: 17066749
And it is to be noted that the probability of picking half pill in the last stage is 1, and the last stage is 2N

So, we know..

P(1) = 0
P(2) = 1/N
P(3) = 2(N-1)/N
...???...
P(2N) = 1
0
 
LVL 37

Expert Comment

by:Harisha M G
ID: 17066852
Sorry.. P(3) = 2(N-1)/N²
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 17066901
Here is my Excel simulation.  You can change the starting conditions (1000, 0) and k.

                   http://www.geocities.com/d_glitch/Pills.xls

So I see k=2.  Still trying to understand why it doesn't regulate to 0.5 later though.

             1  -  exp(-2n/N)
P(n)  =   ------------------           for N >> n >> 0
                     2

0
 
LVL 27

Expert Comment

by:d-glitch
ID: 17068720
This isn't true:
>>   Note that the system will tend to regulate itself so that the number of whole pills and half pills is the same.

If you start off with  W = N whole pills and  H = 0 half pills and run the experiment to the end,
you are guaranteed to pull out N whole and N half pills in 2N trials.

So the average probabilities for whole and half pills in 0.5.

The probability for pulling half pills starts at 0, and grows.  It has to be more than 0.5 at the end of the experiment.

When the number of whole and half pills is equal, the effects of pulling one or the other are not symetric.
=====================================================================

I do believe my mini Monte Carlo model is correct.

If you start with W(0) = N  and  H(0)=0  

                                  N *( exp( -n/N) - exp(-2))
I estimate     W(n)  =  --------------------------------       but it still needs a tweak or two
                                           1-EXP(-2)

                    H(n)  =  2*(N - W(n)) - n

                    PH(n) = H(n)/(W(n)+H(n))       ==>            probability of pulling a half pill after n trials


According to the latest model it fits pretty well:

                        http://www.geocities.com/d_glitch/Pills2.xls


The top chart is W(n)  H(n)    and    W(n)+ H(n)

The second chart is  PH(n) observed and calculated.
0
 
LVL 27

Accepted Solution

by:
d-glitch earned 200 total points
ID: 17073097
I have a better and more accurate albeit numerical solution to the Pills Problem.

Let   W(n=0) = N     and    H(n=0) = 0

If you know W(n), you can find:         H(n)  =  2*(N - W(n)) - n

So                                        W(n) + H(n)  =  2*N  - W(n)  - n


You can write a difference equation for the expected value of W(n+1) in terms of W(n)

             W(n+1)  =  W(n)  -  (Prob of pulling a whole pill on trial n)

             W(n+1)  =  W(n)  -  W(n)/( 2*N - W(n) - n)


You can integrate this eqaution from W(0)=N to solve the problem

=========================================================

Here is my latest Monte Carlo Model:    http://www.geocities.com/d_glitch/Pills3.xls

     For W(0) = 1000,  it finds W(1999) = -0.01   and    H(1999) = 1.01     <== Excelent precision

     The probability of pulling a half pill after 1999 trials PH(1999) approaches 1 as it should.

    The top chart is W(n)  and H(n)   observed and calculated
    The second chart is  PH(n) observed and calculated.                           <== This fit is much better than before.
         
0
 
LVL 25

Author Comment

by:InteractiveMind
ID: 17076988
Thanks all.

I can actually somewhat understand the logic behind your solution d-glitch :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Solving an equation 8 62
java constructor error 8 101
scores100 challenge 3 98
Math homework question 5 80
Dependencies in Software Design In software development, the idea of dependencies (http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29) is an issue of some importance. This article seeks to explain what dependencies are and where they …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now