This textbook attempts to give you an overview of the commonly used basic mathematical models as well as a wide range of applications. In this first chapter, we provide a rough overview of the modeling process and discuss some models you are probably already familiar with.
What is Modeling?
Types of Mathematical Models
Stochastic models tend to be more complex to analyze and often require computational algorithms to implement. These are implemented using computers to simulate the situation using a wide range of parameter values and reviewing the resulting output with statistical analyses.
Modeling with Equations
Proportion of nectar consumed per flower·Number of flowers visited Time spent at each flower·Number of flowers visited. Using the definition of F(t), the rate of nectar collection simplifies to. t+.5)(t+τ), measured as proportion of nectar per second.
Modeling with Recurrence Relations
The parameter represents the rate at which the prey population declines due to predation and represents the natural rate of growth of the prey population in the absence of predators. The parameter represents predator population growth due to predation and represents the natural rate of predator growth.
Modeling with Differential Equations
If the two quantities depend on each other, a system of recurrence relations arises. To solve for (1.5), we first define a new variable y(t) =kQ(t) +b, then differentiate and replace to give dy.
Stochastic Models
For example, if Q(t) represents the population at time t, then the population will eventually approach −b/k, a positive value.
Exercises
Suppose that a forager consumes a food resource at the rate r(x) = 1+ahxax, where xis is the density of the available resource. For this problem, we assume that a steady (equilibrium) amount of drug now remains in the bloodstream after each dose.
MATLAB Basics
To refer to specific elements in the vector, use the command R(n), for example R(3) should return the third element of the vector, the number 7. If you want to round to the next smallest integer, use the command floor.
MATLAB Functions and Terminology
Say we want a list of numbers from a to b in increments of size inc - we can use a:inc:b. If instead you wanted a list of n equally spaced numbers from a to b, you could use linspace(a, b, n).
Plotting Points and Curves
Using ezplot()
For example, we can call the ceil() function with pi as a single argument using ceil(pi). There are other built-in MATLAB functions that return boolean values (true or false) - for example isprime() is a function that returns a 1 (true) if the number is prime and a 0 (false) otherwise.
Using plot()
We can create our own functions that do whatever we program them to do, and we'll have a chance to practice this in later chapters. The functions we used are said to be built-in because they come loaded into MATLAB.
The Symbolic Toolkit
The reason is that MATLAB interprets x as a matrix and tries to use matrix multiplication to calculate xx, which is not defined. To tell MATLAB to apply the operation to each element, use the dot (.) before the operation, whether +, -,∧ or .
For Loops
The line inside the for loop for the code segment above uses a semicolon to suppress output to the command window. All values are stored in the variable x instead of just the most recent one.
While Loops
We could vectorize the code to store each term or the partial sum at each step in the while loop. Therefore, x remains 2, and the line inside the while loop will run forever (or until the program crashes).
Conditional Statements
The code segment below takes each number from 1 to 10 and shows whether it is divisible by 2, 3, or 5. If, for example, i is 6, it will show that it is divisible by 2 - but the following elseif statement is not checked .
Exercises
However, the fixed-point iteration method can be used to solve an equation such as lnx+ 2 =x, which does not have a closed-form solution. Using the above pseudocode, a basic MATLAB script to find the fixed point is given here.
MATLAB function files
On line 10, we display a comment on the command line, indicating that the iteration does not converge. You must call the program from the command line (or from another function file).
The Bisection Method
With each iteration in the process, the length of the interval containing the root is halved. This means that the error cannot exceed b−a2n where a and b are the endpoints of the original interval and n is the number of iterations.
Newton’s Method
The other difference is shown in lines 4 and 8, where Newton's method is applied instead of the fixed point iteration. Then there is a closed interval I containing such that Newton's method above converges for any initial guessx0∈I.
Exercises
For an added challenge, consider the Mandlebrot set, a set of points in the complex plane that satisfy a certain property. Write a MATLAB program that plots a grid of points in the Mandlebrot set in the region of the complex plane.
Matrix Review
Use the command v(1,2) or just v(2) to return the second element of the row vector. To solve by back solving, remember that each row of the matrix corresponds to an equation, x1 + x2 + x3 = −1.
Eigenvectors and Eigenvalues
If v is an eigenvector associated with an eigenvalue λ, then αv is also an eigenvector associated with λ for any α∈R. In summary, the eigenvalues of a diagonal matrix are simply the entries on the diagonal, and the eigenvectors are the corresponding columns of the identity matrix.
Summary of MATLAB commands
Exercises
Note the conditions that lead to exponential decay of the population (r < 0 or 1 +r < 1) and the conditions that lead to exponential growth (r > 0 or 1 +r > 1). Let K be the maximum carrying capacity of the population that the environment can support (this is also known as the carrying capacity of the population).
Linear Dynamical Systems
There are three possibilities for the nature of the solutions toxk+1 =Axk, k≥0 as they relate to the fixed point at the origin. If some of the eigenvalues have absolute value greater than 1, while others have absolute value less than one, then we say the origin is an ascent point.
State, Age, and Stage Matrix Models
As with many population models, we will only keep track of the females in this population. We can now describe the total number of individuals at a given time in each of the three classes as a state vector.
Markov Chains
An absorbing Markov chain has one or more states in which the probability of remaining in the state is 1. It turns out that the probability of being absorbed into the absorbing state, when starting from transient statej, is given as the (i, j) entry of the matrix productBF.
Higher Order and Nonlinear Discrete Dynamical Systems
The parameter β represents the conversion rate at which an encounter between two species results in a decrease in prey and an increase in predation. Plot the settlement curves of the prey and predator population versus time, and a trajectory plot of the two populations together.
Exercises
Euler’s Method
Dashed line is analytical solution, solid lines are approximations using Euler's method with h = 0.1 (middle, in blue) and h = 0.4 (bottom, in red). Dashed line is analytical solution, solid lines are approximations with Euler's method meth= 0.1 (middle, in blue) and h= 0.4 (bottom, in red).
Improved Euler’s Method
On the other hand, the error in the improved Euler method decreases faster. The maximum error obtained by the improved Euler method is shown to decrease at a rate proportional to h2.
Qualitative Analysis of Differential Equations
In addition, even an adjusted harvest rate may not reflect the actual harvest in the case of underfishing or overfishing. To account for this in the model, we can adjust with a linear harvest rate H(x) =hxw which is proportional to the population.
Systems of Differential Equations
We can also establish an improved Euler method for systems analogous to (6.5), with Eqs. Refer to Activity A.0.50 for an example of applying Euler's method of systems to solve a predator-prey model.
Qualitative Analysis of Systems of Differential Equations
In these y0 = 0 lines, there is no growth in the y direction, so we only have horizontal directional changes given by the horizontal arrows. These are represented on the graph by the points in which the anx0 = 0 zero wedge intersects the ay0 = 0 zero wedge.
Linear systems
On the other hand, if even one of the eigenvalues is positive, the solution will tend to ±∞. If the real part of the eigenvalue, α, is negative, then the solutions must tend to zero.
Nonlinear Systems of Equations
We will need to evaluate the Jacobian at each equilibrium and then find the eigenvalues of the resulting matrix J(z∗). There are exceptions - for example if x= 0 then the phase plane diagram (see Figure 6.4) suggests that the points will tend towards (0,2).
Exercises
Use the pseudocode in Section 6.1.1 to write a MATLAB code segment to implement Euler's method for solving an initial value problem of the formx0(t) =f(t, x) withx(t0) =x0 and drawing its solution by time. Use the pseudocode in Section 6.1.2 to write a MATLAB code segment to implement the improved Euler's method for solving an initial value problem of the formx0(t) =f(t, x) withx(t0) =x0 solve and draw his solution against time.
Continuous Random Variables
To find the probability that X is in the setE= [a, b], it makes no sense to write P. Then we just need the probability that X is in each subinterval, and can use that to estimate the probability.
Properties of Random Variables
One way to shorten this code is to have MATLAB generate all the numFlips random numbers in a single line. However, it is relatively simple to use your simulation to generate a good approximation of the confidence interval.
Monte Carlo Integration
Under the right conditions, it is possible to prove that the approximation approaches the analytic value of the integral axis approximations. In the Monte Carlo integration method, the integral is approximated by calculating the average An = 1nPn.
The Binomial Distribution
To summarize: The binomial distribution is used to model the number of successes from the independent trials. We must multiply this probability by the number of ways in which the ksuccesses can occur from the set of ntrials, nCk.
The Normal Distribution
See Activities and Exercises A.0.60 - A.0.62 for simulations generated with a random variable that is normally distributed. Calculating probabilities for a normal random variable in MATLAB requires Statistics and the Machine Learning Toolbox.
Waiting Times
The Poisson Distribution
Assume that telephone calls arrive at a police station at an average rate of λ= 4 calls per minute. a) Find the probability that there are exactly 3 calls during one minute. Again, the Statistics and Machine Learning toolbox could be used to calculate this sum, but it is easy enough to find in MATLAB using
The Exponential Distribution
Now suppose we want to find the probability of waiting more than t time units for an event. Assuming there is only one line, find the probability that more than 5 people will be served during a 10-minute period. a) Let T be the time of waiting in line. d) Note that we could calculate the integral R3.
Sampling from the Exponential and Poisson Distributions
We recall that the exponential distribution has the probability density function f(x) =λe−λx, and the cumulative distribution function F(x) = 1−e−λx. Suppose that we now want to make a probability histogram, which means that the height of the bar corresponds to the proportion of elements that lie in the interval.
Stochastic Processes
Poisson Processes
In Definition 7.8.3, note that the probability of more than one birth in a time interval of size hiso(h). In other words, it is small enough that the probability of more than one birth occurring in a given time interval is negligible.
Birth Death Processes
It turns out that the expected value of X(t) is E(X(t)) =X(0)eβt, which suggests that this model is a probabilistic version of the differential equation model dxdt =βx. As you might guess, the expected value of this general birth-death process will be given by solving the differential equation.
Exercises
In the code segment above, comments are the text segments to the right of the % symbols. What happens to the amount of the drug in the body when the time becomes large. e).