[ADMB Users] Interpolation while optimising

Ian Taylor Ian.Taylor at noaa.gov
Fri Oct 8 18:37:11 PDT 2010


  Sorry, one more email.

I went ahead and posted my quick and dirty spline 
testing model, associated R code, and a plot of 
the fit and various resulting derivatives at 
http://admb-project.org/community/tutorials-and-examples/splines. 
Additional examples could easily be added to that 
folder, especially from folks who know how to 
apply these concepts to real world problems. And 
one day splines will presumably get added to the 
documentation as well.
-Ian

On 10/8/2010 5:01 PM, Ian Taylor wrote:
>  Mark,
> Thanks for sharing this. Your email is now 
> referenced in the FAQ at 
> http://admb-project.org/documentation/faq#splines.
> I would also add that trial and error (in lieu 
> of knowledge of this subject) tells me that the 
> two additional values that you have set to 0 in 
> the line
>
>  vcubic_spline_function 
> splinefn=vcubic_spline_function(splinex,spliney,0.0,0.0) 
>
>
> are the second derivative of the spline function 
> at the first and last values of splinex.
>
> One day, the documentation will describe all 
> this stuff, but for now, the email record 
> certainly helps.
> -Ian
>
> On 10/8/2010 8:13 AM, Mark Payne wrote:
>> For future reference, here is the answer 
>> courtesy of Derek (with a few edits from me).
>>
>> The spline system in ADMB is based around a 
>> class called vcubic_spline_function. The way 
>> these classes work is when you declare 
>> something of type
>> vcubic_spline_function it automatically calls 
>> spline() to set up things for splint(). Then 
>> when you make a call to the type you just set 
>> up it calls splint() to do the interpolation. 
>> The class hides these details. so for example 
>> you might have something like this:
>>
>> vcubic_spline_function interp_func(x, y, dfl, 
>> dfr);  // this calls spline() behind the scenes
>> interpolated_val = interp_func( some_x_val );
>> other_interp_val = interp_func( 
>> some_other_x_val ); // this calls splint() 
>> behind the scenes
>>
>> And here's an example from my procedure section:
>>
>>   dvector splinex(1,nages);
>>   dvar_vector spliney(1,nages);
>>
>>   //... Populate splinex and spliney ...//
>>
>>   //Create the class
>>   vcubic_spline_function 
>> splinefn=vcubic_spline_function(splinex,spliney,0.0,0.0); 
>>
>>
>>   //Evaluate the function
>>   interpolated= splinefn(0.1);
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: Derek Seiple [mailto:dseiple84 at gmail.com]
>> Sent: Tue 10/5/2010 9:14 PM
>> To: Richard Methot
>> Cc: Mark Payne; users at admb-project.org
>> Subject: Re: [ADMB Users] Interpolation while 
>> optimising
>>
>> I have replaced those functions that you 
>> mentioned ( spine() and
>> splint() ). They are still in the replacement 
>> branch but they will be
>> merged into the trunk soon. The names will be 
>> the same and they should
>> produce the same output as the old ones. They 
>> will be replaced with
>> the new beta release.
>>
>> Derek
>>
>> On Tue, Oct 5, 2010 at 7:38 AM, Richard 
>> Methot<Richard.Methot at noaa.gov>  wrote:
>>> When I need to join two discontinuous 
>>> functions in a differentiable way, I
>>> do something like:
>>>
>>>   f1(x)  for x<X
>>>   f2(x)  for x>=X
>>>   steep=10.;  // or larger value depending on 
>>> expected magnitude of x-X
>>>   join(x) =1./(1.+mfexp(steep*(x-X))));  // so 
>>> is steep and centered on X
>>>
>>> // composite function is then
>>>   f(x) = f1(x)*join(x) + f2(x)*(1.-join(x));
>>>
>>>   this is not perfect and depending on the 
>>> slope of f1 and f2 near X may
>>> result in a small wrinkle in the composite 
>>> function, but it has served my
>>> purposes.
>>>
>>> Rick Methot
>>>
>>> Mark Payne wrote:
>>>> Hi,
>>>>
>>>> I have been wondering about this for quite 
>>>> some time. What is the
>>>> "correct" way to do  interpolation in ADMB, 
>>>> so that you don't run into
>>>> problems with discontinuous gradients? I see 
>>>> that there are a series of
>>>> cubic spline interpolation functions in 
>>>> there, spine(), splint() but that
>>>> they are also marked for replacement. Is 
>>>> there something else in the works
>>>> or is this the best approach?
>>>>
>>>> Cheers,
>>>>
>>>> Mark
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at admb-project.org
>>>> http://lists.admb-project.org/mailman/listinfo/users 
>>>>
>>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at admb-project.org
>>> http://lists.admb-project.org/mailman/listinfo/users 
>>>
>>>
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at admb-project.org
>> http://lists.admb-project.org/mailman/listinfo/users 
>>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users 
>



More information about the Users mailing list