1
$\begingroup$

Ok, I need to write a java algorithm which simulates the SMOOTH function written in IDL where the SMOOTH function is given by $$ R_i = \begin{cases} \displaystyle \frac{1}{w} \sum_{j = 0}^{w-1} A_{i+j+w/2} \quad &\text{if}\;\; \frac{w-1}{2} \leq i \leq N - \frac{w+1}{2} \\[1ex] \displaystyle A_i &\text{otherwise} \end{cases} $$

The problem is I don't understand how that algorithm works. I know there is already a similar post regarding boxcar averaging. But the algorithm seems to be different. What I understand in this equation is that there is two state (if statement), the first one is calculating the weight average, the second one is to ignore the boundary. In the first equation, I think I got the summation notation, it starts from $0$ to $(w - 1)$. What I don't get is the one inside summation Ai+j-w/2.

The following is the sample data (just corner part of large data) that was calculated using IDL. I used weight 5 to calculate this.

0           0.3271947   0.6183698   0.841471    0.9719379
0.3271947   0.4541381   0.6782335   0.8694523   0.98077
0.6183698   0.6782335   0.8092117   0.932708    0.9967949
0.841471    0.8694523   0.932708    0.987766    0.9954079
0.9719379   0.98077     0.9967949   0.9954079   0.9508516
0           0.3271947   0.6183698   0.841471    0.9719379
0.3271947   0.4541381   0.6782335   0.8694523   0.98077
0.6183698   0.6782335   0.7850659   0.8642555   0.8968759
0.841471    0.8694523   0.8642555   0.8920734   0.8822442
0.9719379   0.98077     0.8968759   0.8822441   0.8311055

Please, explain me how that algorithm works.

Thanks

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.