DaisyCS100M SP08FVLChap7 - Chapter 7 The Second Dimension...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 7 The Second Dimension 7.1 From j to i Transition Matrices 7.2 Contours and Cross-Sections Visualizing F ( x, y ) 7.3 Cool It! Simulation on a Grid As we have said before, the ability to think at the array level is very important in computational science. This is challenging enough when the arrays involved are linear, i.e., one-dimensional. Now we consider the two-dimensional array using this chapter to set the stage for more involved applications that involve this structure. We shall use the term “matrix” interchangeably with 2-dimensional array. To get acquainted with double subscripts and the jargon of rows and columns, we consider in § 7.1 a modeling problem in which a matrix, made up of probabili- ties, interacts with a one-dimensional array. The underlying simulation tracks the migration of populations that probabilistically move among a Fnite set of islands. Just as plot can be used to help us visualize the behavior of a function f ( x ), the function contour can help us visualize the behavior of a function f ( x, y )that depends on two variables. Instead of handing over a vector of f -evaluations as with plot , we now must hand over a matrix of f -evaluations to contour so that it can display the level-sets, i.e., “elevations.” A critical notion is that of a mesh , the name we give to the Fnite set of points at which we evaluate f ( x, y ). These matters are discussed in § 7.2 In the last section we develop a simulation that models the cooling of a rect- angular plate. The simulation tracks the temperature changes on a mesh that is evenly distributed across the rectangle. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Chapter 7. The Second Dimension 7.1 From j to i Problem Statement Suppose we have four inhabited islands S 1 , S 2 , S 3 ,and S 4 .( F o re x am p l e , Oahu, Kauai, Maui, and Lanai.) It is observed that each year the inhabitants move from island to island. Data is gathered to reveal more details about the migration pattern and an array of transition probabilities is determined as shown in Figure 7.1. The probability of moving from S 3 to S 4 is .18, the probability of “staying put” To From S 1 S 2 S 3 S 4 S 1 .32 .17 .11 .46 S 2 .18 .43 .32 .33 S 3 .27 .22 .39 .14 S 4 .23 .18 .18 .07 Figure 7.1. Transition Probabilities if you live in S 2 is .43, etc. Assume that four million people are equally distributed among the four islands in year Y . Estimate the distribution of population in year Y +5. Program Development To get a feel for what is involved in this problem, let us predict the population of island S 1 after one time step. We must account for the contributions from each of the four islands and so New S 1 Pop = (Prob Moving from S 1 to S 1 ) × (Current S 1 Pop) + (Prob Moving from S 2 to S 1 ) × (Current S 2 Pop) + (Prob Moving from S 3 to S 1 ) × (Current S 3 Pop) + (Prob Moving from S 4 to S 1 ) × (Current S 4 Pop) To make this precise, suppose that x isa4 -by -1arrayw iththepropertythatthe value of x(i) is the number of people living in island S i at the start of a given time step. Likewise, let y be a 4-by-1 array with the property that the value of y(i) is
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/30/2008 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell University (Engineering School).

Page1 / 21

DaisyCS100M SP08FVLChap7 - Chapter 7 The Second Dimension...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online