: ) wonderful world ( :

the metasyntactic variable

distribution of tablets

leave a comment »

I used to consume nicotine tabs (giving up smoking :). I ate a half at a time. When getting a whole tab out, I cut it into two and put a half back. I experienced a higher and higher probability of getting a half during the lifecycle of such a pack. I was curious how this distribution looks like, so asked help from friends regarding the exact math behind and finally got a solution which is like the one below.

tabs

tabs

Notationally, let n1 denote the number of whole, and n2 the number of half tabs.

Number of whole tabs in step t+1 is n1(t+1), namely you can get a whole or a half (in step t+1), this is respectively:


                /   \
             n  | t |            /              \
   /     \    1 \   /            |    /   \     |
n  | t+1 | = ------------------- | n  | t | - 1 | +
 1 \     /      /   \      /   \ |  1 \   /     |
             n  | t | + n  | t | \              /
              1 \   /    2 \   /                  

                /   \
             n  | t |
              2 \   /               /   \
           + ------------------- n  | t |
                /   \      /   \  1 \   /
             n  | t | + n  | t |
              1 \   /    2 \   /          

 

Equation means that you can get a whole, in this case with n1/(n1+n2) probability. The number of wholes decreases by one (you cut that whole tab into half and put one half back). In the other hand you can draw a half tab with n2/(n1+n2) probability and the number of wholes remains the same (you consume the half).

Doing the same with nr. of half tabs as n2:


                /   \
             n  | t |            /              \
   /     \    1 \   /            |    /   \     |
n  | t+1 | = ------------------- | n  | t | + 1 | +
 2 \     /      /   \      /   \ |  2 \   /     |
             n  | t | + n  | t | \              /
              1 \   /    2 \   /                  

                /   \
             n  | t |            /              \
              2 \   /            |    /   \     |
           + ------------------- | n  | t | - 1 |
                /   \      /   \ |  2 \   /     |
             n  | t | + n  | t | \              /
              1 \   /    2 \   /                  

 

When you get a whole, in this case you put back a half (+1 for the halves). Or a half and you consume that (there’ll be one less).

After some simplification, the equations are like this in differential (&dimensionless) form:

       n                    n  - n
.       1            .       1    2
n  = - ------    ,   n  =   -------
 1     n  + n         2     n  + n
        1    2               1    2 

 

Making it simpler (N is the number of tabs, P is the probability you getting a whole):

                                           .    .  .
N := n  + n   , NP := n   ,   N-NP = n   , n  = NP+PN
      1    2           1              2     1        

.    . .  .        .   .         . .   .
n  = N-NP-PN   ,   NP+NP=-P  ,   N-NP-NP = (2NP - N) / N = 2P - 1
 2

.                 .       .
N = P - 1 , PP-P+NP=-P ,  P = - PP/N

 

Finally:

.               .
N = P - 1   ,   P = - PP/N

 

Solving this numerically with below code and plot it with GnuPlot:

  1 #include<iostream>
  2
  3 int main()
  4 {
  5   double dt = 1e-3;
  6   double N = 1;
  7   double P = 1;
  8
  9   for(double t=0; t<2.0; t+=dt)
 10   {
 11     std::cout<<t<<" "<<N<<" "<<P<<std::endl;
 12     double oN = N;
 13     N=N+P*dt-dt;
 14     P=P-P*P*dt/oN;
 15   }
 16
 17   return 0;
 18 }
plot of N and P

plot of N and P

Advertisement

Written by grault

November 16, 2011 - 1:53 pm at November 16, 2011 - 1:53 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.