Upload
isabella-wiggins
View
221
Download
0
Tags:
Embed Size (px)
Citation preview
SE-280Dr. Mark L. Hornick
Numerical Integration
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.
SE-280Dr. Mark L. Hornick
3
When is Numerical Integration needed?
Analytic solution F(x) is not always practical
2
???xF x e dx
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
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
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
SE-280Dr. Mark L. Hornick
7
Zeroth-Order Fit
h h
f0
f2
f1
0h f 1h f
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.
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
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
SE-280Dr. Mark L. Hornick
11
Second-Order Fit
h
f0
f2
f1
h
Parabolic curve
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
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.
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
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).