0% found this document useful (0 votes)
46 views43 pages

Curve Fitting Linear 1

The document discusses various methods for curve fitting including least squares regression, linear interpolation, and curvilinear interpolation. It aims to develop systematic and objective methods for fitting curves to data. Regression and interpolation techniques are used to find trends in data and predict dependent variable values from independent variables. Basic statistics such as the mean, standard deviation, variance, and coefficient of variation are also introduced for analyzing data distributions.

Uploaded by

Wipharat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views43 pages

Curve Fitting Linear 1

The document discusses various methods for curve fitting including least squares regression, linear interpolation, and curvilinear interpolation. It aims to develop systematic and objective methods for fitting curves to data. Regression and interpolation techniques are used to find trends in data and predict dependent variable values from independent variables. Basic statistics such as the mean, standard deviation, variance, and coefficient of variation are also introduced for analyzing data distributions.

Uploaded by

Wipharat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Curve Fitting 1

616201 Chemical Engineering Analysis by Numerical Method


Dr. Wasu Chaitree
Noncomputer methods for curve fitting
- There are many methods to
Least-Squares Regression fit a curve
- Curve fitting depends on
what kind of data you want
to use
Linear Interpolation - The goal is to develop
systematic and objective
methods
Curvilinear Interpolation

2
Regression & Interpolation
• Curve Fitting Given a set of discrete points how do you fill in the
points in between to form a continuum?
• Approximation or regression
• Find a simple function that represents the trend of the curve given that the
data may have measurement error or “noise”
• Those methods allow for evaluating the dependency of one variable on
other variables. They are used to find trends in the analyzed data and
quantify them. Regression analysis attempt to precisely predict the value of
a dependent variable from the values of the independent variables. I
• Interpolation
• The data is exact, so you need to find a function that passes through all the
given points
• The approximated function should pass through all the points in the
previously known set. Then, it could be used to estimate other points not
included in the set.

3
Basic statistics
าเฉล
• Arithmetic means
วนเ ยงเบนมาต
่ ด แต่ล ะ าอ ่ างฉาก
• Standard derivation ่า
It is a measure of how far each observed value is
from the mean.
อ ลกระจ ายมา ก ค.แ ปรปร รนม
The degree of spread in your
ควา มแปรปรว data set. The more spread the
• Variance data, the larger the variance is
in relation to the mean
<V. ่ง า ก.ปร :ม าณ าย
• Coefficient of variations The lower the value of the coefficient of
variation, the more precise the estimate.
ส นส. การ แปร

https://www.biologyforlife.com/standard-deviation.html 4
ส่
ค่
ค่
มู
ข้
ค่
ต่
ที
ค่
ห่
วั
ยู
ยิ
ผั
บี่
Height

SD1

Means
SD1

The heights (at the shoulders) are: 600mm, 470mm, 170mm,


430mm and 300mm.
mean = 394 mm
SD = 147 mm
2 = 21704 mm2

https://www.mathsisfun.com/data/standard-deviation.html
5
A second finding is that the histograms become narrower (and therefore higher) as we move
from trial 1 to trial 10; this illustrates that reaction times vary less and less between our
participants as the experiment progresses. The variance decreases over trials.

https://www.spss-tutorials.com/variance-what-is-it/

6
Coefficient of variations

https://unityweb.qcnet.com/Documentation/Help/UnityWeb/402.htm
7
Basic statistics

Determine means, SD, Variance etc?

-ร

8
9
Histogram
แสดง การกระจา ย ว

ว ม กจะเ า ใก การแจ กแจ งแน
• A histogram used to depict the distribution of data. For large
data set, the histogram often approaches the normal
distribution อม ลท ์ใก ค่า ฉ ย จะ เ
ปกต
NOUMA distribution = ก. แจกแจง ู

Data near the mean are more


frequent in occurrence than
data far from the mean.

= วนเ ยงเบนมาตร
The nomenclature 𝑦𝑦 and 𝒔𝒔𝒚𝒚 refer to the sample
mean and standard deviation, respectively. The
nomenclature µ and σ refer to the population
mean and standard deviation, respectively.
= าเฉล
จะ วนเ ยงเบนมาต
10
ข้
ส่
ตั
ลื
ส่
ค่
ล้
ล้
ข้
บี่
บี่
𝑃𝑃 𝐿𝐿 ≤ 𝜇𝜇 ≤ 𝑈𝑈 = 1 − 𝛼𝛼
Two-side interval
The probability that the true mean of y, µ, falls within
the bound from L to U is 1-α. ่วงความ
α = significant level (1-α=confident interval)

If the true variance of the distribution of y, σ2, statistical


theory states that the sample mean 𝑦𝑦� comes from a normal
distribution with mean µ and variance σ2/n
In general, we really do not know . Therefore, we do not
know where the normal curve is exactly located with
respect to 𝑦𝑦� . To circumvent this dilemma, we compute a
new quality
Standard normal estimate
which represents the normalized
distance between 𝑦𝑦� and µ.
How many standard deviations you are away from the
mean. If a z-score is equal to 0, it is on the mean.
A positive z-score the raw data is higher than the
mean average
A negative z-score reveals the raw data is below
the mean average
11
ช่
มั่
t-distribution
The t distribution is used instead of the
n is small normal distribution when you have small
σ Is not known samples
one tai

0. 25,
𝑡𝑡𝛼𝛼⁄2,𝑛𝑛−1 Read form the table

SEXt =
#xt 12
ม๋
Weight ( 9 ) confidenc

Nati
10 07 ความคลาดเค ่อนมาตรฐาน >S

1003
SE = = = 5.65
99
1
↑ ↑

99 ↳ 51 &12
2.5 2.5
99 SE = 1.5

~(2) Lower ~(U) Upper


99 P SEx trale = 1.53 x 2.1 68
=- 2.160 ? = 1.168
1002 CI =
=996,21 3.26
949
986 S= 5: 65 >US Upper = 5+( SEXtValue(

9ค 1 = 14
=996.21 + 3.2 6
997 1 = 51. = 0.05 twO tails
า One tai =999.47
998
1 3
of = D- 1 = 14- 1 = ก ฝง ละ 1 <- (SEX VALUES
1005 (2) LOWER =

995 I Value = 2.1 60 =996.21- 3.26

= 992.95

992.95 - M 1 999.47
(1 == 3.6
ก็
ถ้
ั่
ลื
ประมาณ ณ า า3 คร

>เอา ่ามาจา
ตาราง
t

13
ค่
ค่
#
1 * ข
D= 8 : &F = 1- 1 = 8- 1:7 6.59

นใจ 95 % 8:51. (tw 0-tailS

-Value = 1,365

0.009921

SE = 6 =

M & 21 = E 0.8752 ( ความก าง อ าล์มเร


จา ก อย -มา
SE = 0.0318
:. 6.5148 > M - 6.6652
CI= SEXtValue = 0.0310 x 2.365 = 0.0752

L= 6.59- 0.0752 = 6.5148

P= 6.59 + 0.075 = 6.665


13
ย่
น้
มั่
ว้
b) First 16 c) all 24

5 = 6.5794, Sy = 0.095845
= 6. Sy = 0.09713

ท= 16 . Of = 1- 1 = 15 25 at 8.05 twO tail /


ก= 24,95 = ↑

95:20nfiden (% %
&= 0.05 ( twO thils)
+Value = 2.069

+Vale = 2.137
SE = Sy = 0.097133 = 0.028254

# 23
↳= 6,5799- 0.095845 ( 2.731) = 6.5208
1
CI=SEX tvalue = 0.028254 X 2.069
0= 6,5799 + 0.095845 ( 2.131) = 6.6389 /

1 (1 = 0.0419

C = 0.095845 ( 2.131) = 0.05 2= 10.6 - 0.8419 = 6.5581


1) ↓ 8= 6.6 + 0.0419 = 6.6419

6.5288 <M.> 6.63896 6.5581 < M - > 6.0419


+WO- +dil

หาง 2 ่งร รวม ก

&5 = จน. ไ จา กท -
=จน. อม ูล ห์ใ

-

14
ความ น
ข้
ผั
มั่
ด้
15
Linear Least-Squares Approximation
• The goal is to make a linear function that comes close to
fitting the given data points
• The closeness is determined by the error or residual

𝑦𝑦 = 𝑎𝑎0 + 𝑎𝑎1 𝑥𝑥 + 𝑒𝑒
𝑒𝑒 = 𝑦𝑦 − 𝑎𝑎0 − 𝑎𝑎1 𝑥𝑥

Criteria for best fit minimize the sum of residue

17
18
Any line passing through mid-points would satisfy the
criteria Positive and negative errors can cancel out

Minimize sum of absolute value of residual errors may not


get a unique solution Any line within the upper and lower
points would satisfy the criteria

min 𝑀𝑀𝑎𝑎𝑥𝑥 𝑒𝑒𝑖𝑖 = min 𝑚𝑚𝑎𝑎𝑥𝑥�𝑦𝑦𝑖𝑖 − 𝑎𝑎0 − 𝑎𝑎1 𝑥𝑥𝑖𝑖 |

Minimize the maximum residual error may be overly


influenced by outliers Data set with an outlier. The line
is affected strong by the outlier
19
Linear Least-Squares Approximation
• The best idea is to minimize the sum of the squares of the
differences between the measured value and the value
calculated by the linear model
• Advantages
• Positive errors do not cancel out negative errors
• Large errors are magnified
• Unique solution

20
Least-Squares fit of a straight line

𝑦𝑦� 𝑎𝑎𝑎𝑎𝑎𝑎 𝑥𝑥̅ 𝑖𝑖𝑖𝑖 𝑡𝑡𝑡𝑒𝑒 𝑚𝑚𝑒𝑒𝑎𝑎𝑎𝑎𝑖𝑖 𝑜𝑜𝑜𝑜 𝑦𝑦 𝑎𝑎𝑎𝑎𝑎𝑎 𝑥𝑥

21
Least square fit of a straight line How many profit in 2005 S.
บอก แกน * - 1987.5

YearCXS Profit LY) x - (x- 5) <x - 5) . Y

Profit for the year 2005


1=1 19 75 1อ -12.5 156.15 -125
Y= + bx ↓ = x - 1987.5
ท = L 1908 1 -7.5 56.25 -97, 5
=10 + 0.697x =2005- 1987.5
1985 15 -2.5 6.25 -37.5
%
1 = 3.5
1 990
>

O =10 + 0.69 ( 17.5


X = 12.5
2.5 6. 25 5
#
1995 2) 7. 7,5 165
4 = 30.198 08 30.2

200 28 12.5 12.5 35


=6 24-10 24 = 457.5 2x4=305
=15.5 = 1985 + 1990 = 1987.5
&

a= 2
4
=100 = 18
ท 6

b = 2 ( X- /4 = 385 = 0.69

2 <X- 3 4 7.5
APPrOX

+ 4
* *
Year( X Profit # 2x = 11925
1 1 I I
19 75 1อ
34 = 10
( 2 f 9
1408 1
4 4
ก=6
1 1)
1985 15
· 4 2x2 = 23701 375
14 36 1 990 O
· 5 40 04 3xY = 214955
1995 2)
9 7 13 8
200 28
1 · 8 12
=6 24-10
14 9 116 19
8
3XY = 364 24 = Y = UX+ b, h =
ID = 56 34 = 40 524

HD
24 = 92 X +
8
Y = UX+ b, h =
2x4 = & 2X'+ b2X
HD
24 = 92 X + 9 = 0.64

2x4 = & 2X'+ b2X ↓= 0.55 100 = 119259+Sh

0.55 214455 = 23701375 + 119256


48 = 569 + Ob 4 = 0.64x +

364 = 534 +56b Y = 0.69714X- 1367.6


𝑦𝑦 = 0.07124857 + 0.8392857𝑥𝑥

22
x = 18 Y = UX+ b, H = 7

Ex = HD
14 24 = 92 X +

2x4 = & 2X'+ b2X


xy = 119.5
4= 7
𝑦𝑦 = 0.07124857 + 0.8392857𝑥𝑥
24 = LOG + 7h
24 = =14 119.5=1409+ 28

4 = 0.039 x + 0.871
22
-
st-Sr ลด errOU ได
St = ผลรวม ของ ก ง 2ร
(JA
Total sum of the squares around
The standard error of estimate the mean for the dependent
variable, y, is St
าเฉ ยเลข
Based on a set of data (N point) arithmetic average
St = CY-)
sr = ผลรวม ก ลัง(ข ของเ ศษ
รอบ เ นฤ ดถอ
น (M Sy/x = าวชมอรมาตรฐานขอ Sum of the squares of
ย ด การประมาณ residuals around the
Liner least square approx. Sy/x Standard error of estimate
regression line is Sr
St-Sr qualifies the improvement or error
reduction due to describing data in terms of
straight line rather than as an average value
ป บป ุง err
The improvement of the total error is determined by r2
(coefficient of determination) and r is the correlation
coefficient
=สปส. การก หนด = คสพ. าสป
Sy/x < Sy the linear regression
model has good fitness jy/x < Sy เ นรถแบบกา
ลด ถอน ท เห นาะท
&
23
&
ค่
วั
ที่
ส้


สุ
รั
ลั
ที่
ลี่
รุ

ค่
ค่
ป็
ค่
Sx/y Spread around the
regression line
Sy Spread around
the mean

24
JSXY
:SSxY
~
standard error Of estimat
B =

SSxX I
SSE = 65xy-
Use data belOW tO Find SA
S: SSE S
SB1 =
2
* Y
# ↑" xx
H-) c SSXX
4
1 ↳ ! 2
↳ 2 4 4
=SSXY =9 = 0.9
10
3 soxx
4
7) 12
4
S 16 9 SSE = 11.2- 0.9 ( 9) = 3.1
1
5 · 25 36 3
S= 3.1 =1,076530845
2) = 1 5 =55 2x4 = 68 5-

34=17 <Y = 69
=1.0165 = 0.3215
SSxx = 2x- 12x) = 10
1
H /
SSxy = 2XY- 2x24 = 9 ไ ค วร โ
#

SSyy = 24 - ( 343 = 11.3


* ใช ธ ีอ. า
้ว

U
ง่
วิ
วิ
ม่
ช้
2
Sp

𝑦𝑦 = 0.07124857 + 0.8392857𝑥𝑥

Sy/x < Sy the linear


St = 12.7143 regression model has good
fitness
2
24 - /
by =
-1

Sp
SYN =
-I

St- SU
=
I
+

25
เอา สมการ มาจาก ตม. ทีแล
ตย. ม พ
↓ ↑ * ใช้ว อ. ไว
2

& Al

𝑦𝑦 = 0.07124857 + 0.8392857𝑥𝑥
Sp Cy- /
SYN = by =
-I -1

Sy/x < Sy the linear


regression model has good
Y = UX+ b, H = 7 fitness
x = 18
V= St- S 0= 22.7143- 2,4477
HD St (1.714 3
Ex = 14 24 = 92 X +

2x4 = & 2X'+ b2X St = 2 <4-


xy = 119.5

4= 7 24 = LOG + 7h sr = 2 24- &X- 63

24 = =14 119.5=1409+ 28
17,0.5) หา <yi- 40 - dexist
4 = 0.039 x + 0.871 20.5- 0.071- 8.839213( = 0.5 6

+- 0.039x- 0.071 25
ลื
วิ
ธี
พิ
พ์
Linearization of non-linear relationship
• A few types of nonlinear function can be transformed into linear
regression problem
• Exponential model
• Power equation
• Saturation-growth-rate equation

26
27
Y* X* a0 a1

ln y x ln α1 β1
log y log x log α2 β2

1/y 1/x 1/α3 β3/α3

𝑦𝑦 ∗ = 𝑎𝑎0 +𝑎𝑎1 𝑥𝑥 ∗

linear: Y = 9 + bx

non- linear: 4= + bx + exh

x= ax 28
Fittin power FUNCTION Y = &X
↑2
* 4 logx logy XY

4= ax

·
10 = 1092 -> %
%

18910 => 10

takelige: 109eY = 10933AX"


=189ed + l0gx 2x 2 25 2x4

109Y = 109,4 + b109eX


4= ap
give Y = ·109et
A ↓
A= 1 09ed

x= 18 %ex A
a= =
1= A + bx

UX+ b
2x => 3 ( 1094)

} แค
Y=
่เป ยน 2xY => 2 C 109x109Y)
HD
24 = 92 X + 2x ==> 3 <109X
2x4 = & 2X'+ b2X
2x2 => 2 ( 109X
ลี
(1) Y= ab* dePl
(2) 4=
1094 = 1099 + x189b
1094 = 189 9 + bx1092
1094 = 1,099 + 1096. /

Y , 1099 = A, blog
2 :

A + BX
1094 =
Y= &= 109b
Y= At BA
=109 !
Y = UX+ b
1= &X + by A= B= b1092
24 = 99X+
HD => =109 b = A = 10 9 A

2x4 = & 2X'+ b2X

#1094
Find the curve fit x = de** Using Method

Of ledSt sqUAr
5.76 = $( 34) + 5 A

3 = 34 24 = 5.76
48.92 = $( 300) + 34 A
<X = 380
#

1 10 2XY = 40.92
B = 0.025
5 1 1.18 B= bloge
A= 1099
7 12 1.08 A = 0.9788

9 1 1.18
ไม่ องแปล ง
a= 18
0.9788 = 9.52
1,0593 /

12 21 1.3
↓ เพราะ ↑ไม่ไ เปล
↓ b= antil092 2)
1,094 = 1899 + bxloge ีเป
ท ่ม ๆ เ shift -> 109 ( 109)

Y= At BX HOTPRTY = 1094 10.0.825 antilog


b, =10 0.025 =
5

Y= UX+ h=
1,0593

(
HD
24 = 92 X + เป ่ยน ว วแปรเ
2x4 = & 2X'+ b2X
~

4 = BX + A

24 = B2X+HA

2XY = BCX'+ A2X


ี่
ด้
ต้
ลี่
ลี
ตั
Y= BX + A

x= &X + b

9= 7.75 = B = B

=- 0.3 = A = 10982
&3 = 10: 03: 8.

29
Y= BX + A

2( 109X) = 2.079 ( (1094) =


-

2.134


2 < 109X) = 1.769 2 ( 189x1894) = 1.4 B= 2 = 1,75

4= BX + A A= 109 & (
180.3 = 52 = 0.5
SY = BSX + H A
1.75
4 = 0.5/
2xY = B2X+A2X

2,134 = B 22.079) + 5 A

1.42 = B ( 1,769) + 1.079 A

=1.7491 = 1.5

A = - 0.3
29
4 2 ( 10914.1894) - 2 2109X) /094
4 22109X) - ( 2109x)

log α2= a0 𝑎𝑎 ∑ (log 𝑥𝑥 log 𝑦𝑦 − ∑ 𝑙𝑙𝑜𝑜𝑙𝑙𝑥𝑥 ∑ 𝑙𝑙𝑜𝑜𝑙𝑙𝑦𝑦


𝑎𝑎1 = 2
α2= 10a0 𝑎𝑎 ∑(𝑙𝑙𝑜𝑜𝑙𝑙𝑥𝑥)2 − (∑ 𝑙𝑙𝑜𝑜𝑙𝑙𝑥𝑥)

30
Example ดต ดเ ป
Determine the slope that results in the least-squares fit for a straight line with a zero intercept. Fit the following data
with this model and display the result graphically: 14
12
10
8

Y
6
·
4
/
2
0
The sum of the squares of the residuals for this case can be written as, 0 5 10 15 20 25
X
Therefore, the slope can be computed as,

31
ตั
จุ
Practice in class
x y
1 1.5
2 4.5
3 6
4 8.5
5 11

Use least-square regression to


fit these data with that
following model
𝑦𝑦 = 𝑎𝑎𝑒𝑒 𝑏𝑏𝑏𝑏

32

You might also like