Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: ListInterpolate and missing values

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124882] Re: ListInterpolate and missing values
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 10 Feb 2012 05:57:28 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201202091034.FAA18221@smc.vnet.net>

x = {1, 2, 10, , 12, 2, 6, 6, , , 12, 22};

data = Thread[{Range[Length[x]], x}] /.
   {_, Null} -> Sequence[];

f = Interpolation[data,
   InterpolationOrder -> 1];

x2 = f /@ Range[Length[x]]

{1, 2, 10, 11, 12, 2, 6, 6, 8, 10, 12, 22}

Plot[f[t], {t, 1, Length[x]},
 AxesOrigin -> {0, 0},
 Epilog -> {Red, PointSize[Large], Point[data]}]


Bob Hanlon


On Thu, Feb 9, 2012 at 5:34 AM, Mark Coleman <markspcoleman at gmail.com> wrote:
> Hi,
>
> I'm looking for a way to linearly interpolate missing values in a
> large list of numbers such that the interpolated values reflect the
> size of the "gap" between non-missing values. For instance, say I have
> the following list:
>
> x={1,2,10,,12,2,6,6,,,12,22}
>
> The list x has two gaps. A gap of size "1" at x[4], and a gap a size
> "2" at x[10]-x[11]. I'm looking for a linear interpolation method such
> that
>
> x[4] = 11,
>
> x[10]=8, x[11]=10
>
> That is, each of the interpolated values is a constant increment
> between the two surrouding non-missing values. My actually problem has
> millions of such lists, where gaps are dispersed randomly (In thinking
> about his more, missing endpoints could also be interpolated by
> "extending" the line between the two succeeeding or preceeding
> points).
>
> I'm wondering if ListInterpolate can handle this sort of problem
> directly? If not, any help would be much appreciated.
>
> Cheers,
>
> Mark
>



  • Prev by Date: Re: plotting
  • Next by Date: Re: Simply but handy question
  • Previous by thread: ListInterpolate and missing values
  • Next by thread: How to select only points which are inside a domain