Skip to content

Instantly share code, notes, and snippets.

@lshifr
Created December 8, 2012 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lshifr/4238023 to your computer and use it in GitHub Desktop.
Save lshifr/4238023 to your computer and use it in GitHub Desktop.
New description

##LocalDataExtrema

LocalDataExtrema is a simple package providing some basic functionality to locate the positions of extremums in a list of data points.

(* Mathematica package *)
BeginPackage["LocalDataExtrema`"]
(* Test version: 1.0.0 *)
PositionsOfLocalMinimum::usage = "PositionsOfLocalMinimum[lst] returns a list of poistions of local minima in lst";
Begin["`Private`"]
PositionsOfLocalMinimum[lst_List] :=
Flatten@Position[Partition[Sign[Differences@lst], 2, 1], {-1, 1}] + 1;
PositionsOfLocalMaximum[lst_List] :=
Flatten@Position[Partition[Sign[Differences@lst], 2, 1], {1, -1}] + 1;
End[]
EndPackage[]
{
"author"->
{
"name" -> "lshifr",
"email" -> "lshifr@gmail.com",
"url" -> "http://www.mathprogramming-intro.org"
},
"name" -> "LocalDataExtrema",
"mathematica_version" -> "8.0+",
"description" -> "New description",
"url" -> "https://gist.github.com/4238023"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment