MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: restricting interpolating functions to be positive

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106559] Re: [mg106519] Re: restricting interpolating functions to be positive
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sat, 16 Jan 2010 06:12:14 -0500 (EST)
  • References: <higdjs$kfi$1@smc.vnet.net> <201001131058.FAA06854@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

That works much better, thanks!

Bobby

On Fri, 15 Jan 2010 02:18:54 -0600, schochet123 <schochet123 at gmail.com>  
wrote:

> On Jan 14, 12:46 pm, DrMajorBob <btre... at austin.rr.com> wrote:
>> For some data, that works pretty well; for other samples it has HUGE
>> peaks, reaching far above any of the data:
>
> This problem can be avoided by using a transformation that is close to
> the identity for positive values:
>
> trans[x_]=(Sqrt[1 + x^2] + x)/2
>
> inv[y_]=(4 y^2 - 1)/(4 y)
>
> Simplify[{trans[inv[y]], inv[trans[x]]}, y > 0]
>
> To compare the effects of this new transformation with the old one,
> modify the test code slightly:
>
> tryinterp := (data = Sort at RandomReal[{0.1, 1}, {20, 2}];
>   {min, max} = data[[{1, -1}, 1]];
>   f = Interpolation@data;
>   logdata = data /. {x_, y_} -> {x, Log[y]};
>   invdata = data /. {x_, y_} -> {x, inv[y]};
>   expinterp = Exp[Interpolation[logdata]@#] &;
>   transinterp = trans[Interpolation[data]@#] &;
>   plota =
>    Plot[Evaluate@Through[{f, expinterp}@x], {x, min, max},
>     PlotRange -> All];
>   plotb = Plot[Evaluate@Through[{f, transinterp}@x], {x, min, max},
>     PlotRange -> All]; GraphicsRow[{plota, plotb}])
>
> Now evaluate  tryinterp several times
>
> Steve
>
>>
>> data = Sort at RandomReal[{0.1, 1}, {20, 2}];
>> {min, max} = data[[{1, -1}, 1]]
>> f = Interpolation@data;
>> logdata = data /. {x_, y_} -> {x, Log[y]};
>> interp = Exp[Interpolation[logdata]@#] &;
>> Show[Plot[Evaluate@Through[{f, interp}@x], {x, min, max},
>>    PlotRange -> All]]
>>
>> (run it several times)
>>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: sketch a phase portrait for the nonlinear system
  • Next by Date: Re: Re: Simplify with NestedLessLess?
  • Previous by thread: Re: restricting interpolating functions to be positive
  • Next by thread: Re: restricting interpolating functions to be positive