MathGroup Archive 2001

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

Search the Archive


In my letter from yesterday there is a fail.
The function F2 shoud be:
F2[b_,x_]:=Sort[F[b,x],Greater], and not Sort[F1[b,x],Greater]
The function F, is define dawn in the page and it have to be in the 
The all letter shoud be like that:

<< DiscreteMath`Combinatorica`

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

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

1.The balls are equals, the boxes are diferent

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

2.The balls are equals, the boxes are equals

In[3]:= F2[b_,x_]:=Sort[F[b,x],Greater]

3.The balls are diferents, the boxes are equals

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

4.The balls are diferents, the boxes are diferents

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

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

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

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

In[9]:= F4[11,7]
Out[9]= {{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[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.


PD.I don't know how to pas the programs I write in Mathematica to the
e-mail, so I have to copy and paste every sentens, an after to correct the 
signs that can not be convert, and I get confuse.

Descargue GRATUITAMENTE MSN Explorer en

  • Prev by Date: Re: commuting and non-commuting symbols
  • Next by Date: RE: commuting and non-commuting symbols
  • Previous by thread: Re: How big a problem can ConstrainedMax handle?
  • Next by thread: RE: 2D to 3D graphics? and Thickness of Lines and Arcs