MathGroup Archive 2010

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

Search the Archive

FoldList for decaying local maximum?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113849] FoldList for decaying local maximum?
  • From: Garapata <warsaw95826 at mypacks.net>
  • Date: Mon, 15 Nov 2010 05:52:24 -0500 (EST)

Use the following to represent a list of 500 data points:

data = RandomReal[ParetoDistribution[1, 4], 500];

Now, I need to find the decay from a local maximum (typically as time^.
05)

The following illustrates my latest attempt to do this:

data = RandomReal[ParetoDistribution[1, 4], 500];
=E2=80=A8maxData = Rest[FoldList[Max, 0, data]];
=E2=80=A8t = Flatten[Range[1, {#[[2]]}] & /@ Tally[maxData]];
maxDecayed = maxData - (t^.5)*.1;
ListLinePlot[{data, maxData, maxDecayed}, PlotRange -> All]

But this only shows the decay from the maximum data values.  I need to
set a local maximum when:

maxData > data >=  maxDecayed

then begin the decay again from that point.

Note: you may need to run the code a couple of times to see the
condition where a data value exceeds the decay line, but has not
produced a new maximum.

I think I need a different approach to do this, which calculates what
I need in one pass through the list, "data" rather than calculating
maxData and t once then trying to calculate the decay.

So, I think I need a function, which would include the conditions that
either:

1. resets the local maximum and restarts the t count or
2. calculates the decays and increments the t count.

It would include something like:

Which[
data > decayedLocalMaximum, {data, 1},
 (* new local maximum, restarts t at 1 *)

data <= decayedLocalMaximum, {decayedLocalMax - (t + 1)^.05*.1, t +
1}
(* local maximum still in effect so it decays and t increments *)
]

This should give me what I'd need for each successive data point's
calculation?

Then I could use that function, call it "localMaxDecay", in something
like:

FoldList[localMaxDecay, 0, data];

But I'm stumped.

- How do I set up the initial decayedLocalMaximum value (it should
equal data[[1]])?
- How do I keep track of t, the intervals since a local maximum
occurred?
- Will FoldList do this?

 I'm not clear how to approach this.  Any suggestions appreciated.

Thanks,
G


  • Prev by Date: Re: Plotting functions and lines on the same figure?
  • Next by Date: Re: 2-D Butterworth lowpass filter?
  • Previous by thread: Re: Using MapAt with Play
  • Next by thread: band pass or notch filtering?