@muna27,
Hmmm. I don't think this can be done with a simple formula. Here's what I've got:
Let F(b,k,c) be the number of ways to distribute b distinguishable balls into exactly k out of c distinguishable containers. This function will be used in a more complicated function below. As you already know from above:
F(4,0,4) = 0
F(4,1,4) = 4
F(4,2,4) = 84
F(4,3,4) = 144
F(4,4,4) = 24
Here are some more values of F to help with the 4 balls/4 boxes problem:
F(3,0,4) = 0
F(3,1,4) = 4
F(3,2,4) = 36
F(3,3,4) = 24
F(3,3,4) = 0
F(2,0,4) = 0
F(2,1,4) = 4
F(2,2,4) = 12
F(2,3,4) = 0
F(2,4,4) = 0
F(1,0,4) = 0
F(1,1,4) = 4
F(1,2,4) = 0
F(1,3,4) = 0
F(1,4,4,) = 0
F(0,0,4) = 1
F(0,1,4) = 0
F(0,2,4) = 0
F(0,3,4) = 0
F(0,4,4) = 0
For other numbers of balls and boxes, you'll need to compute the various values for F. I don't know of a simple formula for this.
Let G(b,k,c,p) be the probability of observing balls in exactly k out of c distinguishable containers when there are b distinguishable balls each with probability p of being visible.
G(b,k,c,p) = SUM(v=0 to b, {[C(b,v)*p^v*(1-p)^(b-v)]*[c^(b-v)]*[F(v,k,c)]/[c^b]}
The curly and square brackets are only there so I can reference them in the descriptions below.
To compute G, you need to sum the expression inside the curly brackets letting v range from 0 to b.
The expression in the first set of square brackets is the same formula I gave you in an earlier post. It computes the probability that exactly v balls will be visible.
The expression in the second set of square brackets is the number of ways to distribute the invisible balls. Each invisible ball can go in any container.
The expression in the third set of square brackets is the function I defined above. I gave you the values you'll need for the 4 ball/4 box problem.
The expression in the fourth set of square brackets is the total number of ways to distribute all of the balls. Each ball can go in any container.
I get:
G(4,0,4,.9) = 0.0001
G(4,1,4,.9) = 0.0442
G(4,2,4,.9) = 0.4158
G(4,3,4,.9) = 0.4784
G(4,4,4,.9) = 0.0615