MathGroup Archive 2002

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

Search the Archive

Length of monotonic sequencies


Hi

I want to get the lengths of the monotonic rising and falling  parts
in a list l. 
 
for this I can use:

Drop[RotateRight[l] - l, 1];
% /. x_ /; x > 0 -> 1  ;
% /. x_ /; x < 0 -> -1  ;
Split[%]
Length /@ %

I want to include the case of no change in the sequence values which
makes the seqence longer. (flat progression) 
I further want to relax the condition of monotonicity by allowing
shallow drops in the sequences.

for a drop of one unit:
{ 2,3,2,3,4,3,5,3,4,3,7}  gives {7,4} 

for a drop of 2 units:
{2,3,4,2,5,6,5,1}              gives {7,1} 
 
how can the code be written for an arbitrary drop? 

Merkat


  • Prev by Date: Re: How to find and plot real roots?
  • Next by Date: Re: Re: Mathematica & MS Word
  • Previous by thread: RE: How to find and plot real roots?
  • Next by thread: Re: Length of monotonic sequencies