Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Length of monotonic sequencies

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33579] Length of monotonic sequencies
  • From: merkat <cabanc at hotmail.com>
  • Date: Mon, 1 Apr 2002 02:02:13 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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