IT1005 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

IT1005

Description:

population curve of the predator (lion) is steeper and trails the curve of prey ... E. If population of zebra versus lion is plotted, what will we see? ... – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 18
Provided by: steven45
Category:
Tags: it1005 | lion

less

Transcript and Presenter's Notes

Title: IT1005


1
IT1005
  • Lab session on week 12 (8th meeting)
  • 1 more week to go

We will take class photo today! At the end of the
1st hour of this session
2
This Weeks Agenda
  • Discussion of my Term assignment answers.
  • I believe that most of you have seen the same
    tables (for q1),and the same plots (for q2-3),
    but do you curious to know whatare my (Lab TA)
    answers compared with yours?? Note, my answers
    are not 100 correct. This is not official
    answer!
  • Review on
  • Various ODE IVP solvers,
  • Curve Fitting using Matlab, and
  • The initial part of Optimization using Matlab
  • Overview of Lab 8, our last lab
  • Preview of what is in store for the last week
  • Class photo D

3
Term Assignment Q1.A
  • Q1. A. Naïve trapezium rule, definitely
    inaccurate.
  • (b-a)(f(a)f(b))/2, f(a) is (f(0)), f(b) is
    f(1000), the result is very imprecise.
  • Lets observe the plot of f(t) from 0 1000 ? Parameter c controls the curvature of
    f(t).
  • Only if c 0.001 then naïve trapezium rule still
    give a good approximation.

When c is larger, the error around this area
is bigger
Wrong if you draw a triangle here! Note that the
y axis start from 0.5!
We should draw a trapezium ?
4
Term Assignment Q1.B
  • Q1. B. More precise trapezium rule, larger n
    should be more precise.
  • But why all n produces similar values between
    Matlab quad (likely correct) and my traprule2
    (likely not ok)?
  • You get no error because the tested integral
    range is from -10 to 10 and the graph is
    special (symmetrical)
  • (positive-negative errors cancel each other).
    That is how you should explain why there is no
    error.
  • If you change the range of your integral, you
    will see differences!
  • If you do this, you can show that n 2 is
    definitely imprecise.
  • The error from larger/slower n (where it should
    logically be more precise) is likely because of
  • floating point error around t 0. Larger n is
    still better (and slower) for most cases.
  • You can also mention that there is no major
    effect of increasing n when t is far from 0 for
    this f(t) with high c.

5
Term Assignment Q2.A-B
  • Q2. A. IVP, IVs 0.1 0.1
  • Q2. B. Interpretation of the plot the population
    change periodically (roughly every 5 years),
  • population curve of the predator (lion) is
    steeper and trails the curve of prey (zebra) by a
    bit.
  • Bla bla (tell some nice story)
  • Tricky question which ODE solver should I use
    for this case?

No major difference between ode45 and ode15s for
10 years Pick the faster solver then ode15s?
6
Term Assignment Q2.C-D
  • Q2. C. To find steady state solutions, use fsolve
    or solve (symbolic math),
  • Steady state means both dx/dt 0 and dy/dt 0
  • We have two possible steady states x 0.5, y
    1/3 or x 0, y 0 (both extinct)
  • Q2. D. If you supply any of the two steady state
    IVs, lion/zebra population will be unchanged over
    time.
  • The x 0, y 0 can be ignored since it is
    very trivial.
  • NOTE for x 0.5, y 1/3, if you write 0.33,
    the graph may looks curvy (this is imprecise)!

7
Term Assignment Q2.E
  • Q2. E. If population of zebra versus lion is
    plotted, what will we see?
  • A circle (oval/ellipse/egg-shape to be precise)
    but which ODE solver that we should use this
    time?
  • In predator prey relationship, predator depends
    on the prey to survive.
  • If both has non zero population, their population
    count will always be on the border of this
    ellipse.
  • This one looks growing perhaps because of the
    constants a, b, c, d used in the question.
  • Intermezzo
  • If prey extinct, predator also extinct soon (no
    food),
  • but if predator extinct first, prey can survive
    and even fill the earth (no predator D),
  • but this model is inaccurate as we omit the death
    factor of the prey (look at problem description
    again).

ode45 left (steady). ode15s right (growing). Is
it because ode15smore precise or what?I think
ode15s is better
8
Term Assignment Q3.A
  • Q3. A. IVP again, but now 4 ODEs, create a loop
    to compute the dx/dt.
  • Looking at the differential equation, ri is the
    birth rate, a is interaction matrix, we know
    that
  • Species 1 has average birth (1), but is preyed
    by/interact with species 2 3 (total -2.61)
  • Species 2 has least birth (0.72), but is preyed
    by/interact with species 3 4 (total -1.8),
  • Species 3 has most birth (1.43), but is preyed
    by/interact with species 1 4 (total -2.8),
  • Species 4 has 2nd most birth (1.27), but is
    preyed by/interact with species 1, 2 4 (total
    -2.07),
  • Looking at the interaction matrix and the plot
  • Species 1 is likely predator of Species 3 and 4.
  • Species 2 is likely predator of Species 1.
  • Note that there are other ways to describe
  • this plot, e.g. several species competing
  • for the same resource, etc

9
Term Assignment Q3.B-C
  • Q3. B. 3-D plot for 3 species, 3-D plot plus 4th
    axis is color if you want to show 4 species.
  • If these 4 species are alive, their population
    count will fall on the surface of this mesh.
  • Q3. C. Lotka-Volterra, a study of population
    dynamics!
  • Open ended Hard to grade this one

10
Application 5 IVP Solvers
  • Matlab has several ODE IVP solvers
  • Which one to use?
  • Generally, ode45, ok for normal cases
  • But if the ODEs are stiff, use the more precise
    solver
  • ode15s
  • Intermezzo, what do you think the plot of number
    of term assignmentsubmitted by students over
    time will looks like?
  • A stiff plot p, perhaps something like this.

11
Application 6 Curve Fitting
  • This is a graph for my/our research paper (due
    Friday, 11 Apr 08, 6pm)
  • http//www.cs.mu.oz.au/cp2008
  • Look at how I use polyfit/polyval.

12
Application 7 Optimization
  • Hm, fyi, my research is about optimization too.
  • A little bit more complex than what you see in
    your lecture notes,but the idea is the same
    given so many options, choose one optionthat
    minimizes (or maximizes) some objective function.
  • e.g. I deal with problems like TSP (Traveling
    Salesman Problem),n cities, n! possible tours,
    one of the tour is shortest.
  • How to deal with simple optimization in Matlab
  • Code the function that you want to optimize in a
    dedicated function,similar like what we have
    done with fsolve and ODE solver.
  • Call x, f fminsearch(_at_function_handle,
    initial_guess)
  • Wrong initial guess will bring us to local
    optima (good, but not the best).
  • Next fmincon
  • Constraints redefine the search space, the
    global optima may be differentthan the
    unconstrained one.

13
Lab 8 - Overview
  • No ODE (already tested in term assignment), Lab 8
    tests fzero(the leftover from Lab 6), polyfit
    (Curve fitting), and fminsearch (Optimization),
    in fact, fminsearch is used to do curve fitting.
  • Q1. A-B. fzero, this is the former Lab 6 question
    3.If you have not tried this before, do this
    now!PS I have taken out my answers from my ppt
    slides 2 weeks ago.
  • Q1. C. Use polyfit to the results in Q1.B above,
    and plot the graph.
  • Q2. A. Create a function to compute sum of
    squared errors.
  • Q2. B. Use fminsearch to find k1, k2, and k3 that
    minimizesthe error in Q2. A and plot the fit.
  • Should be straightforward,you do not need to
    wait until week 13 to finish this.

14
What is left for next week?
  • Fiuh
  • 10 Labs almost done (we still have Lab 8, due on
    week 13, the last week)
  • I am generous right?, so at least you get
    8..10
  • 20 Midterm test done
  • Compare with my modal answer, you should
    approximately know your score.Assuming you score
    10..15, your total is now about 18..25
  • 30 Term assignment done
  • Most likely your score will fall in the range of
    20..25 as long as you submit proper
    stuffs!So your total is now about 38..50
  • So, ?? out of 60 of IT1005 grade is roughly in
    your hand
  • Most probably your total is already 40, the
    minimum passing grade (D)
  • If it is, 99 you will pass this module, you can
    skip exam and still pass (with D or C).
  • So, what left is 40 Final exam to decide your
    final score
  • Next week, we will discuss PAST YEAR PAPER (you
    only have 1 sample).
  • Come, if you want to fight for a good score
    (B/B/A-/A/A) ?.

15
Class Photo (1)
  • I always do this every semester
  • You can download our photos here
  • http//www.comp.nus.edu.sg/stevenha/myteaching/re
    cord.html
  • Photos from my Wednesday classes

2B 3B 4B
16
Class Photo (2)
  • Photos from my Friday classes

5A 7A
17
Free and Easy Time
  • Now, you are free to explore Matlab to
  • Do your Lab 8!
  • Review the lessons that you have received during
    IT1005 course!
Write a Comment
User Comments (0)
About PowerShow.com