I have a date/some kind of value array. When I draw it as a chart it looks like this:

I’d like to find its local min and max points. I signed them by blue points on my chart above.
Is there any built in support in .net/linq/c#/f# to get local min max values of an array/list? I googled this topic. I just want to double check it before coding it by my myself and before reinventing the wheel.
Pls. check my sample chart and the blue points on it, it is not just a simple getting min max values from an array!
There is no built-in function in .NET (or F# libraries) that would do that automatically.
To give you some initial idea – it is quite easy to solve this in F# if you only had precise data (i.e. ignoring small spikes in your chart) such that no two following values in the array are the same.
In that case, you can find a minimum by looking for three following values such that the middle value is smaller than the previous and also smaller than the next value. This detects shapes like:
For example, if you have
valuescontaining your data, you can write:This is not going to work for the data in your chart, because it is oversimplified, but it should give you something to start with. In practice, you’ll probably need to add some smoothing (to avoid identifying all the spikes as local minima/maxima).