Re: restricting interpolating functions to be positive
- To: mathgroup at smc.vnet.net
- Subject: [mg106422] Re: [mg106402] restricting interpolating functions to be positive
- From: Mark McClure <mcmcclur at unca.edu>
- Date: Tue, 12 Jan 2010 04:48:18 -0500 (EST)
- References: <201001112352.SAA20983@smc.vnet.net>
On Mon, Jan 11, 2010 at 6:52 PM, dantimatter <google at dantimatter.com> wrote: > I would like to construct an interpolation that can only take on > positive values. The data that I'm trying to interpolate is all > positive, but for some reason the Interpolation[] function 'wants' to > connect the dots by dipping below zero. Is there a way to force > positivity? Or should I simply adjust the InterpolationOrder until it > works? Here's a (too?) simple approach: data = {{0, 2}, {1, 0.2}, {2, 0.2}, {3, 2}}; f = Interpolation[data]; g[x_] := Max[{f[x], 0}]; Plot[{f[x], g[x]}, {x, 1, 2}, PlotStyle -> {Thin, Thick}] You'll lose some smoothness but you'd certainly lose smoothness by decreasing the InterpolationOrder as well. Mark McClure
- References:
- restricting interpolating functions to be positive
- From: dantimatter <google@dantimatter.com>
- restricting interpolating functions to be positive