Permutations and combinations are the two basic ways of counting how many selections can be made from a set of items. A permutation is an arrangement in which order matters: first, second and third place in a race is a permutation of the runners. A combination is a selection in which order does not matter: a committee of three chosen from the same group is a combination. Together they form the core of combinatorics, the branch of mathematics concerned with counting.
Counting underlies probability, since the chance of an event is often the number of favourable outcomes divided by the number of possible ones. In finance, permutations and combinations appear in option pricing on a binomial tree, in working out how many portfolios or pairs can be formed from a universe of assets, and in judging how many strategies a researcher has implicitly tested.
Formulas
The number of permutations of items chosen from distinct items is:
The number of combinations of items chosen from is:
- is the number of items available.
- is the number chosen.
- , read as n factorial, is the product of all whole numbers from 1 to . By convention .
The two are linked. Each combination of items can be arranged in different orders, so . There are always at least as many permutations as combinations.
Worked examples
A fund manager must rank a first, second and third choice from five shares. Order matters, so the count is . If the manager simply needs to pick three of the five to hold in equal amounts, order does not matter, and the count is .
A researcher wants to examine every possible pair among 50 shares for a pairs trading strategy. The number of pairs is . Among 500 shares it is . The count grows roughly with the square of the number of shares, which has practical consequences discussed below.
The binomial distribution and option pricing
Combinations give the number of ways a fixed number of successes can occur in a series of independent trials. If each trial succeeds with probability , the probability of exactly successes in trials is:
This is the binomial probability distribution. Suppose a share is equally likely to rise or fall each day. The probability of exactly six up days in ten is , or about 20.5 percent.
The same counting drives the binomial option pricing model. The model divides the life of an option into steps, at each of which the price of the underlying moves up or down. After steps, the number of distinct paths that contain exactly up moves is , and all of them end at the same price. With four steps there are paths with two up moves and two down moves, but only one path with four up moves. Weighting each final price by the number of paths that reach it, and by the probability of each path, gives the expected value of the option's payoff.
Counting in strategy research
Combinatorial growth explains why data mining is so dangerous in trading research. The 124,750 pairs available among 500 shares, each tested for cointegration at the 5 percent level, would produce more than 6,000 apparent relationships by chance even if none were real. A strategy with five parameters, each tried at ten settings, has versions. Choosing 5 indicators from a library of 40 can be done in ways. The best of so many candidates will look impressive in a backtest whether or not it has merit, which is the essence of overfitting. Knowing the size of the search is the first step in correcting for it.
The same arithmetic applies to portfolio construction. The number of ways to choose 30 shares from an index of 500 is astronomically large, far beyond exhaustive search, which is why portfolio optimization relies on mathematical methods instead of enumeration.
Extensions
Several variations cover cases the basic formulas do not. When items may be chosen more than once, the number of ordered selections is . A four-digit code using ten digits has possibilities. When some items are identical, the count of distinct arrangements is reduced by dividing by the factorials of the repeated groups. Factorials grow extremely fast, so for large problems the counts are estimated with approximations or explored by random sampling and Monte Carlo simulation instead of being listed in full.
In machine learning, a combinatorial form of cross-validation splits a data set into groups and tests on every possible combination of them, producing many test paths from a limited history. Counting principles also sit behind the rules of conditional probability, where the number of outcomes consistent with a given condition replaces the total number of outcomes.