Calculating "combinations".

  • Thread starter Thread starter John Fitzsimons
  • Start date Start date
| Many thanks for your input/explanation.
|

John ....

You're welcome ....

For convenience, a brief summary ....

An N element set has a total of ( 2 ** N ) subset combinations ....

c = ( n! / t! * ( n - t )! ) # combiniations of n things
# taken t at a time

p = ( n! / ( n - t )! ) # permutations of n things
# taken t at a time


Run the factorial program a few times
with different set sizes and check
the results to get a feel for the numbers ....

python factorial.py 3
python factorial.py 4
python factorial.py 5
...
python factorial.py 12

http://fastq.com/~sckitching/Python/factorial.py
[ 2.6 KB ]

The program shows the number of combinations
and permutations for each set size and their totals ...

combin( n , t ) .... c
permut( n , t ) .... p
 
John said:
So all fitwell had 12 Agent shortcuts all he needed to do was have
479,001,600 batch files and he should have "everything covered"
eh ? :-)

In all that, I hope you were able to pick out the answer to *your*
problem. It's not the 12! = 479001600 above. It's 2^12 - 1 = 4095

Just wanted to be sure. :)
 
John Fitzsimons said:
Thanks. I first need to properly understand the difference between
combinations and permutations. Then I will know which is the "correct"
answer. :-)

John: As I understand it, take as an example the sequence 1, 2, 3, 4.

1 2 3 AND 3 2 1 AND 2 1 3 AND 3 1 2 would be permutations.
A set of combinations of any 3 out of 4 would be any 3 different numbers
(without
duplicating the same set of numbers IN A DIFFERENT ORDER).
In either permutations or combinations the number in each selection should
not be repeated in the selection.
3 3 2 OR 1 1 1 would be neither combinations nor permutations in the above
example.

===

Frank Bohan
¶ The advantage of exercising every day is that you die healthier.
 
John Fitzsimons said:
Hi everyone,

One has a list of 12 items. How many "unique" combinations would that
make ? Is it 12 to the power of 12 ? If not then what would it be and
what software could provide the answer please ?

Regards, John.

John: I have a small program HOWMANY (33KB unzipped) to calculate
combinations of any number (from any number up to 170). I wrote it to
calculate lottery odds.
Examples:
Any 5 from 10 = 252
Any 6 from 49 = 13983815
Any 6 from 50 = 15890700
If anyone wants it I'll send it by e-mail
(my address - remove xxx - is (e-mail address removed))

===

Frank Bohan
¶ It's hard to make a comeback when you haven't been anywhere.
 
Frank said:
John: As I understand it, take as an example the sequence 1, 2, 3, 4.

1 2 3 AND 3 2 1 AND 2 1 3 AND 3 1 2 would be permutations.
A set of combinations of any 3 out of 4 would be any 3 different
numbers (without
duplicating the same set of numbers IN A DIFFERENT ORDER).
In either permutations or combinations the number in each selection
should not be repeated in the selection.
3 3 2 OR 1 1 1 would be neither combinations nor permutations in the
above example.

The best way to think of it is that a permutation is an arrangement of
items, while a combination is a selection. Whether or not items can be/
are repeated is a separate issue. But usually, in sample problems etc.,
the items are assumed to be unique so as to make the problem easier to
solve and so that the standard
n(P)r and n(C)r formulas will be valid. These factorial formulas are
relevant ONLY to the unique item situation. Regardless, the best way to
solve such problems is with a necktop, not a laptop. ;-)
 
OK, now you've fired me Q! I my efforts to simplify all this, I
started thinking about another situation and got myself knotted.
Maybe you can help. Let's say it's 12 *non*unique items - 3 red, 4
blue, 5 green. Same problem - how many *unique* *combinations*
(not arrangements) are there for selections of all sizes? I can't
see a simple way of fathoming it.

Sorry, Alan, I had to give up on this quite a while back. I meant to
post my resignation, but forgot until now. The only solutions I can
think of are far from simple or elegant, more like simple brute force.
 
»Q« said:
Sorry, Alan, I had to give up on this quite a while back. I meant to
post my resignation, but forgot until now. The only solutions I can
think of are far from simple or elegant, more like simple brute force.

Me too :). I guess we can't *both* be wrong... pure hard labour looks
like the answer. :-(
 
Me too :). I guess we can't *both* be wrong... pure hard labour looks
like the answer. :-(

Someone have a formula for this?
It's way too big by hand!
12 sets of 1 and so on....
 
Hello;
Here comes the definition:
A combination of n different objects taken r at a time is a
"selection of r out of the n objects with no attention given to the
order of arrangement.

If that definition aggrees with yours then:

The number of combinations of
n objects taken r at a time is denoted by:

nCr, C(n,r),Cn,r or { n/r}

Then:

nCr = n(n-1)...(n-r+1) = n! = nPr
------------------ -------- -----
r! r!(n-r)! r!

Examples
a, b, c taken 2 at a time is: C = 3*2 = 3
3 2 ------
2! (2*1)

we have: ab, ac, bc for 3 combis.
Note: ab is the same combi. as ba but not the same perm.

a, b, c, d taken 3 at a time: C = 4*3 = 2
4 3 -----
3! (3*2*1)
2 combis there.

a, b, c, d taken 2 at a time is: 4*2 = 4
------
2! (2*1)
and now: 4.


When n! is large a direct evaluation of n! is quite a chore.
Stirling's appproximation formula to n! follows:
______________________________
/ _n
n! ~ \/ 2*3.1416n*n at the power of n* e

where e =2.71828.... ..is the natural base of logarithms.
Also: define 0! as 1 (as it is present/ in existence the same way as 1! =
1).

Here's hoping all the"\/ ---- ___"
stay formatted.


"...and that's it folks".
Mikey
 
Hi,
I reread your post:
You're looking for "permutations"
n different objects taken r at a time in an arrangement of r out of the
n objects taken r at a time.


The # of permutations of n objects consisting of GROUPS of which n1 are
alike, n2 are alike, ... is:

n!
----------- where n =n1 + n2 +....
n1!n2!...

The classic example here is:
the # of permutations of letters in the word "statistics" id:

10!
---------- = 50,400 (fifty thousands and four hundred)
3!3!1!2!1!

since we have 3 s's, 3 t's, 1 a, 2 i's and 1 c = 10 letters.

Another one that looks quite(!) like yours:

12! 12*11*10*9*8*7*6*5*4*3*2*1
------ = -----------------------------------------
3!4!5! 3*2*1 times 4*3*2*1 times 5*4*3*2*1

If fuddly-fingers entered it right in the CASIO = 27,720

479 001 600 divided by 17 280 = 27 720

Mikey
 
Hi,
I reread your post:
You're looking for "permutations"
n different objects taken r at a time in an arrangement of r out
of the n objects taken r at a time.


The # of permutations of n objects consisting of GROUPS of which
n1 are alike, n2 are alike, ... is:

n!
----------- where n =n1 + n2 +....
n1!n2!...

The classic example here is:
the # of permutations of letters in the word "statistics" id:

10!
---------- = 50,400 (fifty thousands and four hundred)
3!3!1!2!1!

since we have 3 s's, 3 t's, 1 a, 2 i's and 1 c = 10 letters.

Another one that looks quite(!) like yours:

12! 12*11*10*9*8*7*6*5*4*3*2*1
------ = -----------------------------------------
3!4!5! 3*2*1 times 4*3*2*1 times 5*4*3*2*1

If fuddly-fingers entered it right in the CASIO = 27,720

479 001 600 divided by 17 280 = 27 720

Mikey

That's the answer I got the first time. I think.
And didn't remember how.
Then I had to look at it another way. <sigh>
12 to the (5-2) power. wrong
3 to the 12. wrong
4 to the 15. wrong
5 to the 12. wrong
Then I had realized I had forgotten how to do this stuff.
Cogratulations. I glad someone can do this stuff or it would be a drab and
ugly world out there.
 
Back
Top