Vous êtes sur la page 1sur 4

Mathcad Tutorial on Curve Fitting - Regression

N 20
i 0 N
f ( x)

x 0.1

vxi i x
vyi f vxi

vy
0.5

0.5

1.5

vx

Generate random numbers in order to simulate measurement errors

vy [ vy ( 1 rnorm ( N 1 0 0.1) ) ] vx [ vx ( 1 rnorm ( N 1 0 0.05) ) ]


vy0 rnorm ( 1 0 0.05) 0

vx0 rnorm ( 1 0 0.025) 0

vy
0.5

0.5

1.5

vx

Middle East Technical University, METU, Ankara/TURKEY


1

Dr. Ender CEROLU

Mathcad Tutorial on Curve Fitting - Regression

Line Fit

a
line ( vx vy)
b

a 0.359

b 0.585

g ( x) a b x

1.5

vy
g ( x)

0.5

0.5

1.5

vx x

corr f ( vx) vy 0.967

Calculates the correlation between actual data and


curve fitted data. For perfect fit it is 1.0.

Logarithmic Fit

a
lnfit ( vx vy)
b

a 0.343

b 1.06

h ( x) a ln ( x) b

1.5

vy
g ( x)

h ( x)

corr g ( vx) vy 0.914

0.5

0.5

1.5

vx x

0.5
b logfit vx vy 0.2

0.6

a 0.504
b 0.116
c 0.994

Middle East Technical University, METU, Ankara/TURKEY


2

j ( x) a ln ( x b) c

Dr. Ender CEROLU

Mathcad Tutorial on Curve Fitting - Regression

1.5

vy
g ( x)
h ( x)

j ( x)

corr j ( vx) vy 0.978

0.5

0.5

1.5

vx x

Power Fit

0.5

b pwrfit vx vy 0.2

0.6

vy

a 1.718
b 0.265
c 0.679

k ( x) a x c

1.5

g ( x)
h ( x)

j ( x)
k ( x)

corr k ( vx) vy 0.976

0.5

0.5

1.5

vx x

General Function Fit


F ( x a b) a x b Create a general function that you would like to fit the dat

0.5
genfit vx vy F

0.1
b

a 1.053

b 0.044

Middle East Technical University, METU, Ankara/TURKEY


3

l ( x) a x b

Dr. Ender CEROLU

Mathcad Tutorial on Curve Fitting - Regression

vy
h ( x)

j ( x)

l ( x) 0.5

corr l ( vx) vy 0.967

k ( x)

0.5

1.5

vx x

Middle East Technical University, METU, Ankara/TURKEY


4

Dr. Ender CEROLU