Solved

Probability question

Posted on 2006-07-08
12
378 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article discusses the Chain of Responsibility pattern, explaining What it is;Why it is; andHow it is At the end of this article, I hope you will be able to describe the use and benefits of Chain of Responsibility.  Backgrou…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

19 Experts available now in Live!

Get 1:1 Help Now