MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Balls

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31358] Balls
  • From: "Juan" <erfa11 at hotmail.com>
  • Date: Tue, 30 Oct 2001 04:35:42 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello again.Thanks for helping me whit the question FractionalPart.
I send you here, functions I have programed whit the package Combinatorica.
<< DiscreteMath`Combinatorica`

The problen is how to share b balls in x boxes.
There is 4 cases:

1.The balls are equals, the boxes are diferent

In[1]:= F1[b_,x_]:=RandomComposition[b,x]

2.The balls are equals, the boxes are equals

In[2]:= F2[b_,x_]:=Sort[F1[b,x],Greater]

3.The balls are diferents, the boxes are equals

In[3]:= F3[b_, x_] := (a3 = F2[b, x]; r3 = RandomTableau[a3];
                       PadRight[r3, x, {{}}])

4.The balls are diferents, the boxes are diferents

In[4]:= F4[b_, x_] := (a4 = F3[b, x]; r4 = RandomPermutation[x];
                       Map[a4[[#]] &, r4])


In[5]:= F1[11,7]
Out[5]= {0,2,0,3,5,1,0}

In[6]:= F2[11,7]
Out[6]= {5,2,2,1,1,0,0}

In[7]:= F3[11,7]
Out[7]= {{1,4,6,11},{2,5},{3,8},{7,9},{10},{},{}}

In[8]:= F4[11,7]
Out[8]= {{2,6},{3},{10},{},{1,4,5,7,9,11},{},{8}}


I have also calculate the probability to share b balls in x boxes, and n 
balls at least in one box.

In[11]:= F[b_, x_] := (q = Table[0, {x}];
           Table[r = Random[Integer, {1, x}]; q[[r]]++, {b}]; q)


In[12]:= Prob[b_, x_, n_] := (t = Table[F[b, x], {200}];
             c = Count[Map[MemberQ[#, n] &, t], True]; 0.005*c)

The birthday problem is:
In[13]:= Prob[23,365,2]
Out[18]= 0.515

I get this results:
In[14]:= Prob[90,365,3]
Out[14]= 0.515

In[15]:= Prob[190,365,4]
Out[20]= 0.505

The function BN[x_,n_,p_]= b,
(to get b, knowing x, n, and the probability p)
If n=2, then p=1-x!/((x-b)! x^b), and we can solve this ecuation for b

In[23]:= B2[x_,p_]:=FindRoot[1-x!/((x-b)!x^b)==p,{b,1,x}]

In[24]:= B2[365,.5]
Out[24]= {b->22.7677}

If n>2, then I don't know.

Salutes.Juan


_________________________________________________________________
Descargue GRATUITAMENTE MSN Explorer en http://explorer.msn.es/intl.asp



  • Prev by Date: Zero does not equal Zero
  • Next by Date: Re: Re: Does Mathematica do transparent colors?
  • Previous by thread: RE: commuting and non-commuting symbols
  • Next by thread: weibull distribution