(************** Content-type: application/mathematica ************** Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 8262, 261]*) (*NotebookOutlinePosition[ 8907, 283]*) (* CellTagsIndexPosition[ 8863, 279]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Markov Matrices and the Lake Pollution Project ", "Title", TextAlignment->Center, FontFamily->"Colonna MT", FontSlant->"Italic"], Cell[CellGroupData[{ Cell["Look for the Eigenvector Connection with a Markov Chain ", "Section", PageWidth->WindowWidth, Evaluatable->False], Cell[CellGroupData[{ Cell["Weather Prediction", "Subsection"], Cell["\<\ For each problem below, the entries represent the probability that tomorrow's \ weather will be sunny, cloudy, or rainy, given that today's weather was sunny, cloudy, or \ rainy, respectively. Combination weather could be expressed by {.5,.5,0}(sunny and cloudy both).\ \>", "Text", PageWidth->WindowWidth, Evaluatable->False], Cell[BoxData[{ \(Clear[mk, daystate]\), "\n", \(MatrixForm[ mk = {{1\/3, 1\/3, 0}, {1\/3, 1\/3, 0}, {1\/3, 1\/3, 1}}]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ Now, suppose that today it is sunny and assume that you are in a climate \ where this Markov chain is always accurate in predicting. What will the weather be like \ in 100 days? Note that multiplication of matrices is done with the period rather than the \ times sign.\ \>", "Text", PageWidth->WindowWidth, Evaluatable->False], Cell[BoxData[{ \(\(daystate = {1, 0, 0};\)\), "\n", \(Do[daystate = mk . daystate, {100}]\), "\n", \(N[daystate]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ Change the daystate and see what the prediction is for 100 days ahead. Predict it for 300 days in the future and compare your answers.\ \>", "Text", PageWidth->WindowWidth, Evaluatable->False], Cell["\<\ Now, use Mathematica to find the stable probability vector for a Markov \ matrix\ \>", "Text", PageWidth->WindowWidth, Evaluatable->False], Cell[BoxData[{ \(Clear[p1, p2, p3]\), "\n", \(Solve[{mk . {p1, p2, p3} == {p1, p2, p3}, p1 + p2 + p3 == 1}, {p1, p2, p3}]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ How does this compare to the daystate after 100 days? While we are at it. let's find the eigensystem for the matrix.\ \>", "Text"], Cell[BoxData[ \(Eigensystem[mk]\)], "Input"], Cell["\<\ Look at the eigenvetor associated with the largest eigenvalue (1). How does \ it compare to the daystate you arrived at after 100 days? Now, let's raise our matrix to powers and see what happens.\ \>", "Text"], Cell[BoxData[{ \(mk20 = N[MatrixPower[mk, 20]] // MatrixForm\), "\n", \(mk100 = N[MatrixPower[mk, 100]] // MatrixForm\)}], "Input"], Cell["\<\ Do you see any connection to the eigenvector associated with the eigenvalue \ of 1? Can you explain why all this is happening?\ \>", "Text"] }, Closed]], Cell[CellGroupData[{ Cell["You Try It", "Subsection"], Cell["\<\ You are to apply these ideas to the Markov matrix presented in Part 4 of the \ Lake Pollution Project. Here is some of the information you will gather to \ bromg to class tomorrow.Be certain to read over Part 4, so that you are \ prepared to respond to the requirements as we do some of them in class. First we define the transition matrix and find the stable probability matrix.\ \ \>", "Text"], Cell[BoxData[{ \(MatrixForm[ mlake = {{ .25, .1, 0}, { .75, .25, .15}, {0, .65, .85}}]\), \ "\[IndentingNewLine]", \(Clear[p1, p2, p3]\), "\n", \(Solve[{mlake . {p1, p2, p3} == {p1, p2, p3}, p1 + p2 + p3 == 1}, {p1, p2, p3}]\)}], "Input"], Cell["\<\ To see why this is called the stable probability vector, try out different \ starting vectors and apply the mlake matrix to them each 100 times to see \ what happens in the long run. Change the terms in red and see if it makes any \ difference in the end result. Remember that your initial vector must have all \ positive components that add up to 1. Why?\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"lakestate", "=", RowBox[{"{", StyleBox[\(1, 0, 0\), FontColor->RGBColor[1, 0, 0]], "}"}]}], ";"}], "\n", \(Do[ lakestate = mlake . lakestate, {100}]\), "\n", \(N[ lakestate]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ Now, we will compute the eigensystem for the mlake matrix and see if there is \ any connection to the stable probability vector we found.\ \>", "Text"], Cell[BoxData[{ \(eig = Eigensystem[mlake]\), "\[IndentingNewLine]", \(\(\(Print["\", eig[\([2, 1]\)]\/\(eig[\([2, 1, 1]\)] + eig[\([2, 1, 2]\)] + eig[\([2, \ 1, 3]\)]\)]\)\(\[IndentingNewLine]\) \)\)}], "Input"], Cell["Does this look familiar? How was it scaled?", "Text"], Cell["\<\ Bring these results to class tomorrow and we will discuss them.\ \>", "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell["Part 4 of the Lake Pollution ILAP ", "Section"], Cell["\<\ You are to apply these ideas to the Markov matrix presented in Part 4 of the \ Lake Pollution Project. First we define the transition matrix and find the stable probability matrix.\ \ \>", "Text"], Cell[BoxData[{ \(MatrixForm[ mlake = {{ .25, .1, 0}, { .75, .25, .15}, {0, .65, .85}}]\), \ "\[IndentingNewLine]", \(Clear[p1, p2, p3]\), "\n", \(Solve[{mlake . {p1, p2, p3} == {p1, p2, p3}, p1 + p2 + p3 == 1}, {p1, p2, p3}]\)}], "Input"], Cell["\<\ To see why this is called the stable probability vector, try out different \ starting vectors and apply the mlake matrix to them each 100 times to see \ what happens in the long run. Change the terms in red and see if it makes any \ difference in the end result. Remember that your initial vector must have all \ positive components that add up to 1. Why?\ \>", "Text"], Cell[BoxData[{ RowBox[{ RowBox[{"lakestate", "=", RowBox[{"{", StyleBox[\(1, 0, 0\), FontColor->RGBColor[1, 0, 0]], "}"}]}], ";"}], "\n", \(Do[ lakestate = mlake . lakestate, {100}]\), "\n", \(N[ lakestate]\)}], "Input", PageWidth->WindowWidth], Cell["\<\ Now, we will compute the eigensystem for the mlake matrix and see if there is \ any connection to the stable probability vector we found.\ \>", "Text"], Cell[BoxData[{ \(eig = Eigensystem[mlake]\), "\[IndentingNewLine]", \(\(\(Print["\", eig[\([2, 1]\)]\/\(eig[\([2, 1, 1]\)] + eig[\([2, 1, 2]\)] + eig[\([2, \ 1, 3]\)]\)]\)\(\[IndentingNewLine]\) \)\)}], "Input"], Cell["Does this look familiar? How was it scaled?", "Text"] }, Closed]] }, Open ]] }, FrontEndVersion->"4.1 for Microsoft Windows", ScreenRectangle->{{0, 1024}, {0, 695}}, WindowSize->{496, 599}, WindowMargins->{{18, Automatic}, {Automatic, 23}} ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1727, 52, 141, 3, 166, "Title"], Cell[CellGroupData[{ Cell[1893, 59, 123, 2, 86, "Section", Evaluatable->False], Cell[CellGroupData[{ Cell[2041, 65, 40, 0, 47, "Subsection"], Cell[2084, 67, 341, 8, 109, "Text", Evaluatable->False], Cell[2428, 77, 172, 4, 63, "Input"], Cell[2603, 83, 341, 9, 90, "Text", Evaluatable->False], Cell[2947, 94, 166, 4, 70, "Input"], Cell[3116, 100, 206, 5, 52, "Text", Evaluatable->False], Cell[3325, 107, 152, 5, 33, "Text", Evaluatable->False], Cell[3480, 114, 179, 4, 70, "Input"], Cell[3662, 120, 142, 4, 71, "Text"], Cell[3807, 126, 48, 1, 30, "Input"], Cell[3858, 129, 220, 5, 90, "Text"], Cell[4081, 136, 140, 2, 50, "Input"], Cell[4224, 140, 150, 3, 52, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[4411, 148, 32, 0, 31, "Subsection"], Cell[4446, 150, 406, 8, 128, "Text"], Cell[4855, 160, 285, 7, 110, "Input"], Cell[5143, 169, 379, 6, 90, "Text"], Cell[5525, 177, 300, 8, 70, "Input"], Cell[5828, 187, 161, 3, 52, "Text"], Cell[5992, 192, 288, 5, 147, "Input"], Cell[6283, 199, 59, 0, 33, "Text"], Cell[6345, 201, 87, 2, 33, "Text"] }, Closed]] }, Closed]], Cell[CellGroupData[{ Cell[6481, 209, 53, 0, 39, "Section"], Cell[6537, 211, 207, 5, 71, "Text"], Cell[6747, 218, 285, 7, 110, "Input"], Cell[7035, 227, 379, 6, 90, "Text"], Cell[7417, 235, 300, 8, 70, "Input"], Cell[7720, 245, 161, 3, 52, "Text"], Cell[7884, 250, 288, 5, 147, "Input"], Cell[8175, 257, 59, 0, 33, "Text"] }, Closed]] }, Open ]] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)