Академический Документы
Профессиональный Документы
Культура Документы
0 Axb
1
Content
Linear regression for calibration
Simple linear regression
Weighted linear regression
Error estimation
MATLAB
Solve the linear regression
Multidimensional case
x 10
income ($)
0
0
10
years of education (y)
15
20
Formulate a model
Salary (mostly) depends on
education
Salary = a * x_education + b
6
x 10
income ($)
Cannot explain
single salaries,
but a reasonable
approximation
0
0
10
years of education (y)
15
20
Formalism
Dependent / independent variables,
parameters
Education?
Salary?
a, b?
Independent chosen =
education
Dependent = Salary
Parameters = a, b
Linear model
The signal intensity (y) is a linear
function of the concentration (x):
y=ax
+b
Measuring two different
concentrations, a and b can be
determined:
y1 = a x1 + b
y2 = a x2 + b
7
a=
y1 - y2
x1 - x2
, b=
y2x1 - y1x2
x1 - x2
Is that all?
What about random noise (errors)?
y=ax
+b+e
Has a major impact on the slope and
offset:
y1 = ax1 + b + e1
y2 = a x2 + b + e2
a=
y1 + e1 - y2 - e2
x1 - x2
, b=
( yi - ( axi
i =1
+ b) )
Calculate minimum
Mathematical formulation
nobs
= argmin ( yi
a,b
b
i =1
( a xi
+ b) )
Solve?
Determine minimum of the function SSQ ->
derivative = 0
SSQ
SSQ
= 0,
=0
a
b
nobs
b=
i =1
nobs
yi
i =1
xi2
nobs
nobs
i =1
11
nobs
xi2
i =1
nobs
xi
i =1
nobs
-
xi
i =1
nobs
xi yi
2
, a=
nobs xi yi i =1
nobs
nobs
i =1
xi2
nobs
i =1
nobs
xi
yi
i =1
2
nobs
-
xi
i =1
Statistics
Perfect measurements?
What assumptions were implicitly
made?
Accuracy of the measurements?
Each point had the same absolute error
0.1 1, 1 1, 10 1
13
y1 = a x1 + b + e1
y2 = ax2 + b + e2
M
ynobs = a xnobs + b + enobs
e2 : N (0, s 22)
M
2
enobs : N (0, s nobs
)
r2 =
s1
ax2 + b - y2
M
14
rnobs =
s2
axnobs + b
s nobs
= argmin
a,b
b
i =1
- ( axi + b)
si
b=
i =1
s i- 1yi
nobs
i =1
s i- 1xi2
nobs
i =1
s i- 1xi
nobs
i =1
nobs
- 1
- 1 2
si si xi - si- 1xi
i =1
i =1
i =1
nobs
nobs
s i- 1xi
nobs
yi
15
Good luck
, a=
i =1
si- 1
nobs
i =1
s i- 1xi yi
nobs
i =1
si- 1xi
nobs
i =1
nobs
- 1
- 1 2
si si xi - si- 1xi
i =1
i =1
i =1
nobs
nobs
s i- 1yi
2
Measurement vector
y1
y= M
y
ynobs
Linear model:
16
x1 1
x
1
y=
b+e
M
M
x
1
nobs
continued
Sum of squared errors (weighted)
x1 1
x
1
A =
M
M
x
1
nobs
r = ( Ab - y) S-
0.5
s12
s 22
S =
SSQ r r r
2
yS y 2 A S y+ A S A
T
17
snobs
Solution
Derivative
SSQ
2 AT S 1y + 2 AT S 1A 0
A S A AT S 1y
T
Same as
nobs
b=
i =1
s i- 1yi
i =1
s i- 1xi2
nobs
i =1
si- 1xi
nobs
i =1
nobs
- 1
- 1 2
si si xi - si- 1xi
i =1
i =1
i =1
nobs
18
nobs
nobs
s i- 1xi
2
nobs
yi
, a=
i =1
s i- 1
nobs
i =1
s i- 1xi yi
nobs
i =1
si- 1xi
nobs
i =1
nobs
- 1
- 1 2
si si xi - si- 1xi
i =1
i =1
i =1
nobs
nobs
s i- 1yi
2
80
70
60
50
40
30
20
10
19
10
15
standard concentration (mmol/L)
20
MATLAB
Construct matrix A
A = [ x, ones( size(x) ) ]
20
x1 1
x
1
A =
M
M
x
1
nobs
Calculate a & b
A A AT y
T
Visualization
Plot the measurements & regression line
plot( x, y, sb );
hold on
plot( [0; x(end)], [ b; x(end)*a+b ], r: )
100
90
80
70
60
50
40
30
20
10
22
10
15
standard concentration (mmol/L)
20
23
AT A A T y
1
d d
Sy
dy dy
a 4.874 0.156
b 1.570 1.370
24
100
80
60
40
20
0
-20
6
8
10
12
14
standard concentration (mmol/L)
16
18
20
Weighted regression
Motivation
Measurement error is relative (weight =
1/x)
Measurement error is known
(repetitive measurements)
25
MATLAB
Construct matrix A
x1 1
x
1
A =
M
M
xnobs 1
A = [ x, ones( size(x) ) ]
Construct matrix S
s12
s 22
S=
s nobs
a 5.145
b 0.342
120
100
80
60
Different to:
40
a 4.874
b 1.570
20
27
6
8
10
12
14
standard concentration (mmol/L)
16
18
20
100
80
60
40
a 5.145 0.158
b 0.342 1.110
20
0
-20
28
6
8
10
12
14
standard concentration (mmol/L)
16
18
20
Multidimensional
More than one observable (y)
More than 1 slope / offset
Examples:
Determine coefficients in chemical
reactions
aC 6H12O6 + bNH 4+ + cH 2O + dH + + e HCO3- + f C 3H 5O3- + CH 1.8O0.5N 0.2 = 0
Determine HP coefficients Black-Box
model
29
30
6
H
12
O
6
0
N
charge 0
0 0 0
4
0
1
1
2
1
0
0
1 1 5 1.8
0 3 3 0.5
0 0 0 0.2
1 1 1 0
a
b
c
d 0
e
f
1
6
H
12
O
6
0
N
charge 0
0 0 0
4
0
1
1
1 1 5 1.8
0 3 3 0.5
0 0 0 0.2
1 1 1 0
2
1
0
0
a
b
c
d 0
e
f
1
3
0 1 0 0 0
0 1 0 1 1
E5555555555555
F
A
d
6 0 0 0
12 4 2 1
6 0 1 0
31
b
c
d
e
5
1.8
3 0.5
0
0.2
1 0
E555555
F
A
f
3
f
1
0
0
0
0
1 a
3 1
1 b
5
1.8
6
0
1
0
3
c
3
0.5
1
0 1 0 0 0 d
0
0.2
E5F
1 0 x f
e
0 1 0 1 1 E5
F E555555
F
E5555555555555
F x
d
A
A
f
d
6 0 0 0
12 4 2 1
1 a
3 1
1 b
5
1.8
6 0 1 0 3 c 3 0.5
1
0 1 0 0 0 d
0
0.2
E5F
1 0 x f
e
0 1 0 1 1 E5
F E555555
F
E5555555555555
F x
d
A
A
f
d
6 0 0 0
12 4 2 1
Step 4: Solve
A d xd A f x f 0
1
xd A d A f x f
32
Herbert Pirt
Strain
33
mu
1/h-1
qS
mmol/g/h
qP
mmol/g/h
S1
0.2084
4.9947
1.6525
S2
0.1515
3.7447
1.4274
S3
0.0957
2.495
1.1612
34
A 2
3
qP ,1
qP ,2
qP ,3
1
1
xf = qS
Step 4: Solve
A qS
A
35
qS
More experiments
Strain
36
Lac
addition
mM
mu
1/h-1
qS
qP
mmol/g/h mmol/g/h
S1
0.2084
4.9947
1.6525
S2
0.1515
3.7447
1.4274
S3
0.0957
2.495
1.1612
S1
50
0.2098
5.0141
1.388
S2
50
0.1518 Assume
3.7624 a, b1.2008
S3
50
S1
150
0.1982
5.0141
1.0454
S2
150
0.139
3.7619
0.9052
independent
LAC
0.0946
2.511 of0.9796
ms dependent of LAC
qS ,1 a 1 b qP ,1 m0
qS ,2 a 2 b qP,2 m0
qS ,3 a 3 b qP,3 m0
qS ,4 a 4 b qP,4 m50
qS ,5 a 5 b qP,5 m50
M
qS ,12 a 12 b qP ,12 m150
37
a
b
m0
m50
m150
a
b
q S A m1
m2
m3
38
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
q p ,1,1
q p ,1,2
q p ,1,3
q p ,2,1
q p ,2,2
q p ,2,3
q p ,3,1
q p ,3,2
1 0 0
1 0 0
1 0 0
0 1 0
0 1 0
0 1 0
0 0 1
0 0 1
xf = qS
Step 4: Solve
A qS
A
qS
Inverse cannot be calculated
39