Thread View: sci.math.stat
2 messages
2 total messages
Started by anthony.r.rizzo
Tue, 13 Oct 1992 15:16
least squares fit to function
Author: anthony.r.rizzo
Date: Tue, 13 Oct 1992 15:16
Date: Tue, 13 Oct 1992 15:16
21 lines
1410 bytes
1410 bytes
Some time ago, I asked for net-wisdom on the subject of constrained least squares. Many of you responded, letting me know that I was on track. First, let me thank all those who responded. I've since written my own little program to do constrained least square fits of n-degree polynomials. But now I have a slightly off-the-wall question for you. Read on. ;-) Given some explicitely defined function g(x), say, g(x) = sin(x), can the method of least square errors be applied such that we derive a second function f(x) = a0 + a1*x + a2*x^2 + ... + an*x^n where f(x) is the best least squares fit to g(x)? I know that this request sounds strange. But I have a legitimate application. The application software that I'm using, ANSYS, forces me to input certain quantities as polynomial functions of temperature. So I can't get around using a polynomial. Given this restriction, I at least want to use a best-fit polynomial. Has anyone ever heard of this being done before? Tony Rizzo
Re: least squares fit to function
Author: William Skelly
Date: Wed, 14 Oct 1992 02:02
Date: Wed, 14 Oct 1992 02:02
36 lines
2222 bytes
2222 bytes
In article <1992Oct13.151606.8435@cbfsb.cb.att.com> rizzo@cbnewsf.cb.att.com (anthony.r.rizzo) writes: >Some time ago, I asked for net-wisdom on the subject of constrained >least squares. Many of you responded, letting me know that I was >on track. First, let me thank all those who responded. I've since >written my own little program to do constrained least square fits >of n-degree polynomials. But now I have a slightly off-the-wall >question for you. Read on. ;-) > >Given some explicitely defined function g(x), say, g(x) = sin(x), >can the method of least square errors be applied such that >we derive a second function f(x) = a0 + a1*x + a2*x^2 + ... + an*x^n >where f(x) is the best least squares fit to g(x)? > >I know that this request sounds strange. But I have a legitimate >application. The application software that I'm using, ANSYS, >forces me to input certain quantities as polynomial functions >of temperature. So I can't get around using a polynomial. >Given this restriction, I at least want to use a best-fit polynomial. > >Has anyone ever heard of this being done before? > >Tony Rizzo > Yes. I think you want to check out Generalised Least-Squares fitting routines. I am currently using the one in Numerical recipes for which fitting a polynomial is straightforward. Press et al. recommend their singular value decomposition over least-squares or weighted least-squares routines. If you figure out how to use it you might let me know how I can find the best fit for a spherical variogram using these routines ;-). Cheers, Chris
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads