Professional Documents
Culture Documents
Modeling Basics: Compartment Models Dimensional Analysis Stochastic Modeling
Modeling Basics: Compartment Models Dimensional Analysis Stochastic Modeling
Compartment Models
Dimensional Analysis
Stochastic Modeling
Kishore Pochiraju
Model
Physics Math
Simulation
Computation
Numerical Methods
Basic Concepts: Differentiability
Jacobian
Solution to Linear Simultaneous Equations
Water level
Water outflow
Water inflow
Reservoir
Typical Compartment Model
Room
Heat in Heat out
Temperature (q)
Q_in Q_out
• Sigmoid functions -
Appropriate for
population growth,
diffusion, etc.
An Initial Value Problem
Solution:
What is the initial value?
• Consider:
Eigen expansion of A if
diagonalization is possible
What are stiff ODEs
Steps:
• Assume a function with known functions and unknown
coefficients
Observations
Piece-wise linear
Cubic
linear
• Exact Model
Interpolation/Extrapolation
• Interpolation:
data to be found
are within the
Exact
range of observed
data
• Extrapolation:
data to be found
are beyond the
range of
Cubic observation
data. (not reliable*)
Extrapolation should
With unknown/incorrect functional be avoided whenever
forms extrapolation rarely works! possible
The Regression or Curve Fit Problem
• Definition:
– Given N observations (xi, yi) with a curve/surface with M
unknown coefficients, aj, with N > M.
• Strategy:
– Find the coefficients a, such the to square error of distance
between the model and observations is minimized.
Numerical Example
Error: ei
How to minimize?
Example: If
Y = a0 + a1 x = a0 (1) + a1 (x)
Solving
Can be used for determination of constant coefficients & Any known
functions
y1 1 x1 x12 x13 1
a
1 ... b
1 ...
1 c
...
d
3
yn 1 x n xn2 xn n
32
Implementation in MATLAB
Consider the following data set:
x y
1 4.256430363
3 10.76433253
10 33.36067977
20 64.51141009 This data was created with:
24.5 77.83651186
30.9 95.81242635 Y = 1 + 2*x + 40* sin(px/100)
37.3 112.4582736
43.7 127.6191049
50.1 141.1998026
56.5 153.1689124
62.9 163.5599109
69.3 172.4698563
75.7 180.0554788
82.1 186.5268648
88.5 192.1389938
100 201
Read the data file into Matlab
• Definition:
– Given N observations (xi, yi)
with a curve/surface with M
unknown coefficients, aj, with
N > M.
• Strategy:
– Find the coefficients “a”, such
the square error of distance
between the model and
observations is minimized.
Polynomial Regression
Best Fit Approximations with Least Square Methods
Error: ei
Implementation in MATLAB
Linear Quadratic
cubic Exact
Matlab Example
g n ( x) a0 a1 x a2 x an x
2 n
• That passes through all n+1 points
• Polynomial Interpolation approaches:
– Lagrange interpolating polynomials
– Newton’s divided difference interpolating polynomials
Lagrange interpolating polynomials
n
f n ( x) Li ( x) f ( xi )
i 0
Li ( x)
n
x xk
k 0, k i xi xk
1 i j
Li ( x j ) ij
0 i j
Where the Li are weighting coefficients that are functions of x.
Linear interpolation
f1 ( x) L1 f x1 L2 f x2
x x2 x x1
L1 , L2
x1 x2 x2 x1
x x2 x x1
f1 ( x) f x1 f x2
x1 x2 x2 x1
Quadratic Interpolation
6
8 9
r
1 2
5
2nd order Lagrange interpolating polynomial
f 2 ( x)
x x1 x x2 f ( x0 )
x0 x1 x0 x 2
x x0 x x2
f ( x1 )
x1 x0 x1 x 2
x x0 x x1
f ( x2 )
x2 x0 x2 x1
Each of the three terms passes through
one of the data points and zero at the
other two. The summation of the three
terms must, therefore, be unique
second order polynomial f2(x) that
passes exactly through three points.
Bilinear Interpolation in Grid Square
http://en.wikipedia.org/wiki/
Bilinear_interpolation
2D Lagrange Interpolators
Domain:
r
Value at M located at coordinate (rm, sm) with values Vi known at nodes
Piece-Wise Models and Continuity
• When using Piece-wise functions, the models may or may
not be continuous
• Enforce continuity by forcing the coefficients.
@ x=0.5, both
models produce
the same value –
No discontinuity
In y – C0
continuous