Message Boards Message Boards

0
|
5743 Views
|
8 Replies
|
6 Total Likes
View groups...
Share
Share this post:

[?] Find first local minima?

Dear All,

I have a list as following (for example)

data = {10,8,7,6,5,3,4,5,2,3,2,1,0}

The first local minima is 3.

How can I find this value in Mathematica ?

Thank so much for your help.

POSTED BY: M.A. Ghorbani
8 Replies

What about an "old fashioned" way without sophisticated "modern" functions?

data = {10, 8, 7, 6, 5, 3, 4, 5, 2, 3, 2, 1, 0};

min = data[[1]];
Catch[
 Do[
  If[data[[i]] < min, min = data[[i]], Throw[{i - 1, min}]],
  {i, 2, Length[data]}]]

{6, 3}
POSTED BY: Hans Dolhaine

I agree that the Position function is a viable option, but keep in mind that FindPeaks gives the x-position of the maxima by default. so something like:

sol = {1, -1}*FindPeaks[-m, 0, 0, -Infinity][[1]]

would give you x and y position of the first minimum. If you use

sol = {1, -1}*# & /@ FindPeaks[-m, 0, 0, -Infinity]

you get the same for all minima. Using Mariusz' notation:

ListPlot[CorrelationFunction[data, {100}], 
 TicksStyle -> {{FontSize -> 16, Orange}, {FontSize -> 22, Green}}, 
 PlotRange -> All, AxesLabel -> {Style[x, Large], Style[y, Large]}, 
 Epilog -> {PointSize[0.01], Red, Point /@ sol}]

gives:

enter image description here

Cheers,

Marco

POSTED BY: Marco Thiel

Dear Marco, Mariusz

Thanks again.

I used your solution for my real data. Unfortunately the result shows { }. Please see the attached file.

Regards,

Attachments:
POSTED BY: M.A. Ghorbani

You need write a pattern using Condition to force searching based on numerical equality:

See here (Position->Possible Issues) for more information.

Regards, Mariusz

Attachments:
POSTED BY: Mariusz Iwaniuk

Hi,

don’t use the “2•. You will also need to multiply the x-value by -1.

Cheers,

Marco

POSTED BY: Marco Thiel

Try:

Position[data, 3]
(*  {{6}, {10}} *)

Regards, Mariusz

POSTED BY: Mariusz Iwaniuk

Dear Marco,

That's great.

How can I find the position of this value at the list?

Regards,

POSTED BY: M.A. Ghorbani

Would this work?

-FindPeaks[-data, 0, 0, -Infinity][[1, 2]]

Cheers,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract