       Re: restricting interpolating functions to be positive

• To: mathgroup at smc.vnet.net
• Subject: [mg106519] Re: restricting interpolating functions to be positive
• From: schochet123 <schochet123 at gmail.com>
• Date: Fri, 15 Jan 2010 03:18:54 -0500 (EST)
• References: <higdjs\$kfi\$1@smc.vnet.net> <201001131058.FAA06854@smc.vnet.net>

```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)
>

```

• Prev by Date: Re: More /.{I->-1} craziness
• Next by Date: Re: More /.{I->-1} craziness
• Previous by thread: Re: Re: restricting interpolating functions to be positive
• Next by thread: Re: Re: restricting interpolating functions to be positive