Computational Thinking, Linear Algebra, Python, Jupyter Notebook, Math.
np.ones(n, dtype=np.float32) * np.sqrt(A.sum()/(n*n)) # initial guess for i in range(max_iter): scores = A @ scores nrm = np.linalg.norm(scores) scores /= nrm print(nrm) return scores Question: Why normalize the scores on each iteration? scores = power_method(X, max_iter=10) 0.621209 0.856139