Averages/Simple moving average: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: reformatted the output.)
m (→‎{{header|REXX}}: aligned the output better.)
Line 2,791: Line 2,791:
do k=n%2 to 1 by -1; @.j=k; j=j+1; end /* ··· decreasing values.*/
do k=n%2 to 1 by -1; @.j=k; j=j+1; end /* ··· decreasing values.*/
/*──────────────────────────────────────────perform a simple moving avg.*/
/*──────────────────────────────────────────perform a simple moving avg.*/
say ' ' " SMA with " ' SMA with '
say ' ' " SMA with " ' SMA with '
say ' number ' " period " p ' period ' q
say ' number ' " period" p' ' ' period' q
say ' ──────── ' "──────────" '───────────'
say ' ──────── ' "──────────" '──────────'
do m=1 for n

do m=1 for n /*show simple moving average. */
say center(@.m,10) left(sma(p,m),11) left(sma(q,m),11)
say center(@.m,10) left(sma(p,m),11) left(sma(q,m),11)
end /*m*/ /* [↑] show simple moving avg.*/
end /*m*/
exit /*stick a fork in it, we're done.*/
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────SMA subroutine──────────────────────*/
/*──────────────────────────────────SMA subroutine──────────────────────*/
Line 2,808: Line 2,807:
<pre>
<pre>
SMA with SMA with
SMA with SMA with
number period 3 period 5
number period 3 period 5
──────── ────────── ───────────
──────── ────────── ──────────
1 1 1
1 1 1
2 1.5 1.5
2 1.5 1.5