{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding an equilibrium distribution using the power method" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "A = np.array([\n", " [.8, .6, .8],\n", " [.2, .3, 0],\n", " [0, .1, .2]\n", "])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now find a starting `x`:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], "source": [ "x = np.random.randn(3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, compute $A^{100}x$:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([ 0.84960372, 0.24274392, 0.03034299])" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = A.dot(x)\n", "x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "What does this mean?" ] } ], "metadata": {}, "nbformat": 4, "nbformat_minor": 0 }