Need small help to understand algorithm

Hi! all I am reading one research paper in that I found one peak detection algorithm, I am just trying to understand how it works please anyone help me to convert algorithm to awk as I am not able to understand, here I am attaching that paper also, please help me to understand this logic (Page number 9)

X[n] be an array holds some information

X[n]={5,6,7,8,9........n}

then
How to apply this formula

S(k,i,x,T)=max{x-x[i-1],x-x[i-2]....x-x[i-k]}+max{x-x[i+1],x-x[i+2]...x-x[i+k]}/2

and how can I return resulting value in function S to called function

You are asking two questions: (1) how does the algorithm work and (2) how to implement it in awk.
As regards the first question, it seems you have copied the code from page 9 of the pdf attachment without actually correcting some of the diacritical characters.
In fact, the algorithm is explained in the attachment, as well as has some examples of peak functions defined. So in order to help you with the second question, it is probably best if you study page 5 to 8 of the attachment first.

1 Like