# Pairwise comparison matrix using AHP

Learn how a pairwise comparison matrix turns side-by-side judgments into criteria weights, with the formula, an example, and calculator, Excel and Python options.

A pairwise comparison matrix is the grid at the heart of the analytic hierarchy process (AHP), where you judge two items against each other at a time instead of scoring everything at once. Each cell records how much one criterion or option is preferred over another, and the finished matrix is converted into weights that rank your choices. This page explains the structure, the formula behind the weights, a worked example, and how to build the matrix in a calculator, a spreadsheet or Python. 

## Reading the Saaty scale and filling cells 

The Saaty scale gives each comparison a number from 1 to 9, where 1 means two items are equally important and 9 means one is far more important than the other. You fill only the upper triangle of the matrix and enter the reciprocal in the matching lower cell, so a 3 in one direction becomes one third in the other. The diagonal always holds 1 because every item equals itself, and a full matrix of n items holds n times n entries. Keeping the reciprocal rule intact is what makes the matrix consistent enough to yield usable weights. 

## From matrix to weights with the eigenvector 

The eigenvector method converts a completed pairwise comparison matrix into a set of criteria weights that sum to one. You normalize the matrix by dividing each column entry by its column total, then average each row of the normalized matrix to get its weight. The principal eigenvector of the original matrix gives the same weights, which is why software reports it directly. These weights tell you how much each criterion contributes when you score the options underneath it. 

## Checking consistency with the consistency ratio 

A pairwise comparison matrix can hold contradictory judgments, such as A over B, B over C, and C over A. The consistency index measures how far your matrix departs from perfect order, and the consistency ratio compares that figure with a random baseline for the same size. A ratio low enough against that baseline suggests your judgments hang together well. If the ratio is too high, revisit the entries that clash rather than accepting the weights. 

## Pairwise comparison matrix questions 

### What is a pairwise comparison matrix example? 

A pairwise comparison matrix example with three criteria places 1s on the diagonal and a preference number in each off-diagonal cell, such as rating cost twice as important as speed. The mirror cell then holds the reciprocal, one half, so the matrix stays symmetric in the opposite direction. Averaging the normalized rows produces three weights that sum to one. 

### What is the pairwise comparison matrix formula? 

The pairwise comparison matrix formula takes each entry a(i,j), divides it by the sum of its column, and averages each row of the resulting normalized matrix. That row average is the weight for that criterion or option. The eigenvector approach solves for the vector that the matrix scales without changing direction, and it returns the same ranking of weights. 

### Can I use a pairwise comparison matrix calculator, Excel or Python? 

A pairwise comparison matrix calculator handles the arithmetic once you enter your judgments, and spreadsheet templates do the same with column sums and row averages. Excel suits small matrices where you want to see every cell, while Python libraries compute the eigenvector and consistency ratio for larger ones. Whichever tool you pick, the judgments you enter remain the part that decides the result. 

### Does ranking university choices on UCAS use a pairwise comparison matrix? 

UCAS university choices are ranked by your own preference order, so a pairwise comparison matrix can help you decide that order rather than replace the UCAS process. Comparing two courses at a time on criteria such as location, entry requirements and course content makes the trade-offs visible. The matrix then gives a preference ranking you can carry into your application.
