You are not logged in.
For k colors with n marbles each, I find it to be:
May require some modification when number of marbles are different.
Last edited by gAr (2013-04-27 22:53:23)
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi gAr;
That is a nice one, it will come in handy.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Hi,
Got a recursion to work!
Here's a sage code:
A = 10
B = 10
C = 10
D = 10
def f(a,b,c,d):
if (A-a == 2 or B-b == 2 or C-c == 2 or D-d == 2):
return (A+B+C+D-(a+b+c+d))
return a/Integer(a+b+c+d)*f(a-1,b,c,d) + b/Integer(a+b+c+d)*f(a,b-1,c,d) + c/Integer(a+b+c+d)*f(a,b,c-1,d) + d/Integer(a+b+c+d)*f(a,b,c,d-1)
print f(A,B,C,D)
It returns : 30008/9139
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi gAr;
Yeparoo! Very good!
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yeah, that looks much neater than the formula!
I think this will help in many problems involving probability..
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
Have you tried the formula in post#26 on this problem?
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes, and we must multiply that by 2, I forgot to include that.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
I am not getting the correct answer then, when I multiply by 2 I get:
I am using n = 10 and k = 4.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Perhaps I made a mistake when translating my program to the formula? Or you took out n from the sum ?
Here's the code I used:
def ans(n,k):
summ = 0
for i in range(1,k+1):
pr = 1
for j in range(1,i):
pr *= (k-j)*n/Integer(4*n-j)
summ += (i)*(i+1)/2 * pr * (n-1)/Integer(4*n-i)
return 2*summ
ans(10,4) returns 30008/9139
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
Why the Integer() command?
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
It causes problem like flooring if it's not written..
In python, we need to convert it to float.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
There is a typo in the formula. In post #26 there is (k-i), in post #34, (k-j).
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Oop answer was wrong
Offline
Hi bobbym,
Ah yes, sorry!
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
No problem! Thank you for the formula.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
You're welcome!
I think we can't write a formula like that when the number of marbles are different for different colors, since it involves permutation?
Anyway, I'll stop here, spent almost a day on this one!
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
I will play with it a little in a bit. Right now there is a little bit of an administrative matter to watch for.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Okay..
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
Looks like the worst is over. Now about that formula...
If we hold k = 4 and vary n then we come up with this:
for n = 2, 3, 4, ...
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
That's a good one!
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Oh yes and quite useless unless you have exactly 4 colors.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Anyway, we can easily extend the recursion if not the formula for any number of variables and experiment with the terms.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
There are a lot of possibilities here.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline
Yes.
"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?
"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."
Offline
Hi;
I am going to get a little sleep. See you later.
In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.
Offline