[SciPy-User] eigenvectors <-> nth root of row product
Tue Oct 18 09:24:19 CDT 2011
Please excuse me if this question is out of topic or scope for this forum. I have just started
using numpy and I would like to apply it to a practical problem that I have been researching.
I have been reading about a method called AHP (Analytic Hierarchy Process) or the Saaty
method [see: wikipedia article if you are curious http://en.wikipedia.org/wiki/Analytic_Hierarchy_Process]
which is a " is a structured technique for organizing and analyzing complex decisions." and which
involves, for the purposes of this group, calculating eigenvectors from matrices.
After trawling the net for a guide to the calculation implied by this process, I found this pdf
describes a method for arriving at eigenvectors which I will quote somewhat:
THE AHP THEORY
Consider n elements to be compared, C1 ... Cn and denote the relative ‘weight’
(or priority or significance) of Ci with respect to Cj by aij and form a square
matrix A=(aij) of order n with the constraints that aij = 1/aji, for i ≠ j, and aii = 1, all i.
Such a matrix is said to be a reciprocal matrix.
The weights are consistent if they are transitive, that is aik = aijajk for all i, j, and k.
Such a matrix might exist if the aij are calculated from exactly measured data.
Then find a vector ω of order n such that Aω =λω. For such a matrix, ω is said
to be an eigenvector (of order n) and λ is an eigenvalue. For a consistent matrix, λ = n .
THE AHP CALCULATIONS
There are several methods for calculating the eigenvector. Multiplying together the
entries in each row of the matrix and then taking the nth root of that product gives
a very good approximation to the correct answer. The nth roots are summed and
that sum is used to normalise the eigenvector elements to add to 1.00. In the matrix
below, the 4th root for the first row is 0.293 and that is divided by 5.024 to give 0.058
as the first element in the eigenvector.
The table below gives a worked example in terms of four attributes to be compared
which, for simplicity, we refer to as A, B, C, and D.
A B C D of values Eigenvector
A 1 1/3 1/9 1/5 0.293 0.058
B 3 1 1 1 1.316 0.262
C 9 1 1 3 2.279 0.454
D 5 1 1/3 1 1.136 0.226
Totals 5.024 1.000
I have represented the matrix in a python file where I try to compare the author's
method of arriving at eigenvectors with numpy's eig function output:
import numpy as np
from numpy import array
m = array([
[1., 1/3., 1/9., 1/5.],
[3., 1., 1., 1.],
[9., 1., 1., 3.],
[5., 1., 1/3., 1.]
w, v = np.linalg.eig(m)
nth_root_prod = array([pow(row.prod(), 1./row.size) for row in m])
ev = nth_root_prod / sum(nth_root_prod)
Unfortunately, I am unable to reconcile numpy's output with the author's. I'm speculating
now: but perhaps the numbers don't reconcile because the author, as he has hinted above
has taken the eigenvalue or lambda = n (which in this case is 16). If this is the case,
then I would have to generate the eigenvectors for the matrix above where lambda = 16.
Presumably there is a way in numpy to do this.
My first question, for those of you who are more familiar with these kinds of problems
am I completely on the wrong track here?
Many thanks for any help on this.
More information about the SciPy-User