  # Permutations and Combinations

When we talk of permutations and combinations we often use the two terms interchangeably.

 In statistics, the two each have very specific meanings. The permutation of a number of objects is the number of different ways they can be ordered: the position is important. With combinations, one does not consider the order in which objects were placed.

This algorithm (program in Matlab) calculates the number of permutations and combinations of N objects taken D at a time.

The full Matlab code is:

% Clears variables and screen
clear; clc

n = input('Total number of objects: ');
d = input(
'Size of subgroup: ');

% Computes and displays permut. according to basic formulas
p = 1;
for i = n - d + 1 : n
p = p*i;

end
str1 = [num2str(p) ' permutations'];
disp(str1)

% Computes and displays combin. according to basic formulas
str2 = [num2str(p/factorial(d)) ' combinations'];
disp(str2)

Example 1:

How many permut. and combin. can be made of the 26 letters of the alphabet, taking five at a time?

We run the code above and enter:

Total number of objects: 26
Size of subgroup: 5

7893600 permutations
65780 combinations

Example 2:

How many different ways can 12 computers be repaired if the workshop can only support 2 at a time?

We run the Matlab m-file above and enter:

Total number of objects: 12
Size of subgroup: 2

The answer (with no doubt) is:

132 permutations

66 combinations

From 'Permutations and Combinations' to home

From 'Permutations and Combinations' to 'Probability and Stats' Menu  