![Page 1: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/1.jpg)
SE-280Dr. Mark L. Hornick
Numerical Integration
![Page 2: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/2.jpg)
SE-280Dr. Mark L. Hornick
2
In the PSP, definite integrals of the t-distribution are used to calculate the significance of a correlation and the prediction interval of an estimate.
Requirement: Integrate an arbitrary f(x)
from a to b
( ) ( )
( ) ( ) ( )b
a
F x f x dx
f x dx F b F a
The problem is that there is no (simple) closed-form solution for the integral of the t-distribution function.
![Page 3: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/3.jpg)
SE-280Dr. Mark L. Hornick
3
When is Numerical Integration needed?
Analytic solution F(x) is not always practical
2
???xF x e dx
![Page 4: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/4.jpg)
SE-280Dr. Mark L. Hornick
4
Numerical Integration Approach
Fit polynomial (or something else) to f(x) All at once In discrete segments Polynomial degree can vary
Integrate resulting polynomial(s) Using well-known formulas
![Page 5: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/5.jpg)
SE-280Dr. Mark L. Hornick
5
0
0.2
0.4
0.6
0.8
1
1.2
0 1 2 3
f(x)
Integration Example
2xf x e
![Page 6: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/6.jpg)
SE-280Dr. Mark L. Hornick
6
0
0.2
0.4
0.6
0.8
1
1.2
0 1 2 3
f(x)
Zeroth-Order Fit
h
![Page 7: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/7.jpg)
SE-280Dr. Mark L. Hornick
7
Zeroth-Order Fit
h h
f0
f2
f1
0h f 1h f
![Page 8: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/8.jpg)
SE-280Dr. Mark L. Hornick
8
0
0.2
0.4
0.6
0.8
1
1.2
0 1 2 3
f(x)
Zeroth-Order Fit
0
0 1 1
nx
n
x
f x dx h f f f
hNote: Sometimes “w” is used instead of “h” for step width.
![Page 9: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/9.jpg)
SE-280Dr. Mark L. Hornick
9
First-Order Fit (trapezoidal rule)
h h
f0
f2
f1
0 1
2
f fh
1 2
2
f fh
![Page 10: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/10.jpg)
SE-280Dr. Mark L. Hornick
10
0
0.2
0.4
0.6
0.8
1
1.2
0 1 2 3
f(x)
First-Order Fit (contd.)
0
0 1 12 22
nx
n n
x
hf x dx f f f f
![Page 11: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/11.jpg)
SE-280Dr. Mark L. Hornick
11
Second-Order Fit
h
f0
f2
f1
h
Parabolic curve
![Page 12: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/12.jpg)
SE-280Dr. Mark L. Hornick
12
Simpson’s Rule
Simpson’s 1/3 rule: parabolic segments
0
0 1 2
2 1
4 2
2 43
nx
n n nx
f f fhf x dx
f f f
CoefficientsFirst and last terms: 1Odd terms: 4Even terms: 2n must be even
![Page 13: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/13.jpg)
SE-280Dr. Mark L. Hornick
13
In all these methods, we must choose an appropriate step size.
A small step size generally gives a better fit, but takes longer to calculate and may increase round-off error.
A large step size is usually less accurate, but faster to compute.
![Page 14: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/14.jpg)
SE-280Dr. Mark L. Hornick
14
Often the best choice is to iterate to the "right" step size.
Choose # ofsegments (n1)
Calculate integral(save as pa)
Calc new segments(nj = 2*nj-1)
|pb - pa| < eCalculate integral
(save as pb)
Set pa = pb
Done (answer = pb)"e" is the desired result precision
"h" is derived from "n", the number of
segments
Yes
No
![Page 15: SE-280 Dr. Mark L. Hornick Numerical Integration](https://reader036.vdocuments.site/reader036/viewer/2022062407/56649e175503460f94b028eb/html5/thumbnails/15.jpg)
SE-280Dr. Mark L. Hornick
15
Pro
bab
ilit
y d
ensi
ty
Distributions are important statistical functions that we often need to integrate numerically, since no closed-form solution exists.
2
21
2
x
F x e
Normal Distribution: The probability density function for a large sample size
Its integral represents a cumulative probability over some range (more on that in a later).