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

2.The balls are equals, the boxes are equals

In:= F2[b_,x_]:=Sort[F1[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:= F[b_, x_] := (q = Table[0, {x}];
Table[r = Random[Integer, {1, x}]; q[[r]]++, {b}]; q)

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

_________________________________________________________________
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