       Balls2

• To: mathgroup at smc.vnet.net
• Subject: [mg31366] Balls2
• From: "Juan Erfá" <erfa11 at hotmail.com>
• Date: Wed, 31 Oct 2001 03:30:56 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello.
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
begining.
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:= 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:= F1[b_,x_]:=RandomComposition[b,x]

2.The balls are equals, the boxes are equals

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

3.The balls are diferents, the boxes are equals

In:= F3[b_, x_] := (a3 = F2[b, x]; r3 = RandomTableau[a3];

4.The balls are diferents, the boxes are diferents

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

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

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

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

In:= F4[11,7]
Out= {{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:= 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:= Prob[23,365,2]
Out= 0.515

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

In:= Prob[190,365,4]
Out= 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:= B2[x_,p_]:=FindRoot[1-x!/((x-b)!x^b)==p,{b,1,x}]

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

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

Salutes.Juan

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 http://explorer.msn.es/intl.asp

```

• 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