Does anyone know an algorithm to detect peak trends in a graph?

Hi all,

I have a C# Windows Forms application that has a graphical component.
In here a simple line graph is displayed from a series of data.
I would like a routine to detect the peak value within this graph.
In the following Graph:

 Example Graph
I would like it to return the maximum value in the area highlighted...
Any ideas how I might go about doing this?
Any help would really be appreciated.

Best regards,

James
LVL 4
James AtkinSenior Principle Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill NolanOwner, Lead Technology ProgrammerCommented:
Simply scan the data from X_Start to X_End and save the largest Y value.
0
James AtkinSenior Principle Software EngineerAuthor Commented:
Hi,
I think I probably worded my question badly...
I am after the peak trend in a graph, not just the highest point.
As the graph shows, there are several spikes, however the area I am interested in is a prolonged period of 'activity'...
I'm sure there is a statistical term for this, but I have no idea what it is!
Thanks,
James
0
BardobraveCommented:
Ok, let's see.

First of all you'll need to define some sort of variables to define when a trend is valid for you. Let's say, for example, that you consider a trend when y value exceeds 50 during a period of 10 x units.

Then you can build and algorithm that loops through X values seeking Y values over 50. When a Y value over 50 is reached, the X and the Y of this point are stored into a dictionary and you move on to the next X value, if the corresponding Y value is also greater than 50 you add that X and Y to the dictionary and continue. If not, if the dictionary has less than 10 elements (your x number of elements that define a trend) you empty it, if it has more than 10 elements you add this dictionary to a list of trends and continue looping through your X values with a new fresh dictionary.

After the X loop you'll have a list of dictionaries with the X,Y values of each trend found in the graphic. It should be easy enough to make anything you want with that data.

This algorithm is very crude and could be highly improved, but we would need more info on your requirement to do so. However, I think you can catch the glimpse of the idea and use it.

Hope it helps.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James AtkinSenior Principle Software EngineerAuthor Commented:
Hi Bardobrave,

Your solution sounds like exactly what I am after!!!
Thanks a lot  :-)

Best regards,

James
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.