- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I'm quite new at this so please excuse me if I did not see a thread that would already answer my question.
I am looking for a routine that would be able to fit a polynomial equation to a large set of data. But there is a slight twist: I need this function to be strictly monotonous; the first derivative should be strictly positive over the whole domain ofinterest, and thesecondderivative should be positive or null over the domain. (I was trying to use excel as a first go, but the resulting fitting curve was oscillating, I can't have that)
I know it is quite straightforward to check the first and second derivative of a polynomial equation when we have its coefficients, but how can I use this to constrain my fitting curve?
Thank you very much for your help
Cheers
Quentin
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code in the att. file performs a polynomial fit of arbitrary order to x,y data arrays.
Since, as noted, derivitives are easy to check, presumably this code will point the way, and these routines can be imbedded (by you) in a larger code context which prepares the raw data, and then evaluates the fit according to your criteria in some iterative manner.
The evaluation may be monotonous, but presumably you will be able to find a fit which is sufficiently monotonic.
Since, as noted, derivitives are easy to check, presumably this code will point the way, and these routines can be imbedded (by you) in a larger code context which prepares the raw data, and then evaluates the fit according to your criteria in some iterative manner.
The evaluation may be monotonous, but presumably you will be able to find a fit which is sufficiently monotonic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Paul for your answer.
I don't quite understand how your code works though. could you please add some comments or at least explain what each subroutine is doing so that I can understand and modify your code to fit my needs.
In your program do you enter the X and Y values manually here:
! raw data to be fitINTEGER, PARAMETER :: nvals = ! YOUR POINTCOUNTREAL, DIMENSION(nvals) :: x = !(/ YOUR x DATA HERE /)REAL, DIMENSION(nvals) :: y = !(/ YOUR y DATA HERE /)
I think if you were able to explain the function of each subroutine I should be able to get it but without any comment it is very hard to understand what it is doing.
Cheers
Quentin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The x() and y() arrays can be created, read or accessed in whatever manner you want; the code sample is just that, a sample, and you will need a bit of extra surrounding structure for your application, in which presumably the data will be fit iteratively multiple times until your monotonicity criterion is met.
The polynomial fit routine is an F90 update of SVDFIT which possibly came from Numerical Recipes or some similarly venerable reference; google provides tons of info on SVDFIT, it's well-known and well-proven.
The polynomial fit routine is an F90 update of SVDFIT which possibly came from Numerical Recipes or some similarly venerable reference; google provides tons of info on SVDFIT, it's well-known and well-proven.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page