|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Identifying Local Maximas in a plot
Does anyone know of an algorithm to identify Local maximas in a plot? (in VB). Any advice on it be helpful.
|
|
#2
|
||||
|
||||
|
wow - I'm sorry, but no. Can you tell me what a local maxima is? It would seem that if you have any algorithm for it, then it should apply to any object oriented language - it's just a matter of writing the necessary classes to implement that algorithm. Do you have an algorithm or equation for it at all?
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#3
|
|||
|
|||
|
Fisherman,
You're right. I still need to develop an algorithm for it first and this forum may not be the right place to search for algorithm itself. Do u know of any site or forum where I can get help from in the algorithm itself? I admit I should have done more searches online before posting my question here. Local maxima, as you may think, are smaller peaks (other than the highest peak) in a plot. Thanks. |
|
#4
|
||||
|
||||
|
wow - 2 years of calculus right out the window!
I remember now, but I don't know of any way to find them, short of doing a bubble sort within a desired range (maybe of an array). Probably the best way to do it would be to not think of it as a graph, but instead as a dataset. How will you be determining which range you want the local maximum of? |
|
#5
|
|||
|
|||
|
You're right again when u say I need to think of it as a dataset. From my limited knowledge, Bubble sort compares consecutive values and swaps them until they appear the way we want; The algorithm will certainly need to compare the data values close to each other to find the maximum (local ); but I am not sure if there's a need to swap them coz all it needs to do is identify and record the local maxima.
I have a set of conditions which will already provide me with the data range I am interested in...I just need to get the algorithm ![]() any ideas that pop into your mind? ![]() |
|
#6
|
||||
|
||||
|
well, I wrote a simple little helper function for a dll of common functions that I use at work - it fairly simple, but if you know the values that you want to compare, it works..
Code:
Public Function Max(FirstValue As Variant, secondvalue As Variant) As Variant
If FirstValue > secondvalue Then
Max = FirstValue
Else
Max = secondvalue
End If
End Function
'YOU CAN CALL IT RECURSIVELY LIKE SO
dim intMax as integer
intmax = Max(max(max(4,5),(1,2),9),3)
'like any good function - you can call it in a loop with an array, too
I don't know if that will help you or not, but I've used it several times. It doesn't matter what order the numbers are in, it will still find the max - it also works on characters (though you don't really need it for that) - if nothing else, maybe it will put you on a track towards your goal Last edited by Fisherman : December 8th, 2003 at 11:42 AM. |
|
#7
|
|||
|
|||
|
Hey fisherman,
I just uploaded a gif file in a new thread in which I have shown the local maxima. From what I can tell from your code, it will be able to identify the middle peak and may miss the other two peaks on the sides. Am I correct? If yes, is it possible to modify the codes so that it catches all the peaks and not just the highest value in a dataset? Thanks alot for your untiring efforts! I owe you one ![]() |
|
#8
|
||||
|
||||
|
I see what you mean now, the code I wrote could most likely be modified for the functionality you want, but I think it would be easier to simply declare another array, set the second array=to your original one, and use the bubble sort to order the array according to your measure of magnitude. Then, you can just pull the first three (or four or five or etc...) items from that array.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Identifying Local Maximas in a plot |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|