note macro smooth_2.obe
note This MLwiN macro smoothes Y as a function of X.
note Column numbers of X and Y must be given as B1 and B2.
note Width of smoothing window must be given as B21.
note The smoother calculates a simple moving average of
note note values Y(i)...Y(i + 2*B21), where Y(i) is ordered according to X.
note Output is: ordered X values in C401,
note corresponding original Y values in C402,
note smoothed Y values in C403.
note (The B21 first and last values in C403 are meaningless.)
note Further output, without the meaningless rows:
note ordered X values in C404,
note corresponding original Y values in C405,
note smoothed Y values in C406.
note Columns C398 and C399 are used as temporary variables.
note input values are
print b1 b2 b21
echo 0
sort CB1 CB2 c401 c402
calc c403 = c402
calc c399 = c402
calc c398 = c401
aver c402 b24 b25
loop B40 1 B21
mlla "cons" C399 C399
calc c403 = c403 + c399
mlla "cons" C399 C399
calc c403 = c403 + c399
mlla "cons" c398 c398
endloop
calc c403 = c403/(2*B21+1)
discard 1 b21 c401-c403 c404-c406
calc b24 = b24 - b21
calc b23 = b24 - b21 + 1
discard b23 b24 c404-c406 c404-c406
erase c398 c399
echo 1
plot c406 c404