home *** CD-ROM | disk | FTP | other *** search
- .MCD 20000 0
- .CMD PLOTFORMAT logs=0,0 subdivs=1,1 size=5,15 type=l
- .CMD FORMAT rd=d ct=10 im=i et=3 zt=15 pr=3 mass length time charge
- .CMD SET ORIGIN 0
- .CMD SET TOL 0.001000
- .CMD MARGIN 0
- .CMD LINELENGTH 78
- .CMD SET PRNCOLWIDTH 8
- .CMD SET PRNPRECISION 4
- .TXT 0 41 1 39
- a1,38,39,37
- Copyright (c) 1988 by MathSoft, Inc.
- .TXT 1 40 1 34
- a1,33,78,32
- /EQUATIONS FOR MEDIAN SMOOTHING
- .TXT 1 -58 1 33
- a1,32,77,31
- SMOOTHING WITH RUNNING MEDIANS
- .EQN 1 59 1 12
- ORIGIN~0
- .TXT 0 15 1 57
- a1,56,78,55
- Define a function to find the median of three numbers.
- .TXT 1 -95 2 76
- a2,75,77,129
- This application illustrates the use of running medians to smooth a data
- sequence. First set the origin and read in the data.
- .EQN 1 80 2 20
- mx(a,b)~max(({2,1}÷b÷a))
- .EQN 2 -64 1 21
- V~READPRN(RMDATA)
- .EQN 1 64 3 28
- md(a,b,c)~min(({3,1}÷mx(a,c)÷mx(b,c)÷mx(a,b)))
- .TXT 1 -80 4 79
- a4,78,76,270
- The smoothing replaces each term of the sequence by the median of that term
- and its two neighbors. This process is repeated until it produces no
- further changes. Press [F9] to calculate. If the value of check isn't
- zero, increase n and recalculate.
- .TXT 4 79 2 81
- a2,80,78,88
- The sequence to be smoothed is in elements zero through N of the array V.
-
- .TXT 1 -79 1 24
- a1,23,76,22
- number of smoothings:
- .EQN 0 25 1 7
- n~5
- .TXT 0 12 1 24
- a1,23,39,22
- check for completion:
- .EQN 0 24 1 13
- check=?
- .EQN 1 20 1 13
- N~last(V)
- .EQN 0 27 1 11
- k~0;N
- .TXT 1 -101 1 16
- a1,15,71,14
- original data
- .TXT 0 39 1 16
- a1,15,23,14
- smoothed data
- .EQN 1 -46 7 30
- &&V[k{1,1,6,25,l}@N&0&k
- .EQN 0 38 7 30
- &&W[k{1,1,6,25,l}@N&0&k
- .TXT 0 41 2 77
- a2,76,75,141
- Initialize a two-column array for the smoothing. Each iteration replaces
- one column of the array A with a smoothed version of that column.
- .EQN 3 2 2 10
- A{52}~V
- .EQN 0 13 2 10
- A{52}~V
- .EQN 1 14 1 11
- j~1;n
- .TXT 2 -28 1 15
- a1,14,78,13
- [Ctrl][PgDn]
- .TXT 2 0 2 75
- a2,74,76,123
- The index mod(j+1,2) is alternately 1 and 0, so the equation defining A
- below writes alternately to columns 1 and 0 of A.
- .EQN 3 0 2 26
- r(A,k,j)~A[(k,mod(j+1,2))
- .EQN 3 -2 3 82
- A[(k,mod(j,2))~(j*0){54}if(mod(k,N)≈0,r(A,k,j),md(r(A,k-1,j),r(A,k,j),r(A,k+1,j)))
- .TXT 5 2 2 78
- a2,77,78,119
- The process is complete when columns 0 and 1 of A are equal. The smoothed
- sequence is in column 0 and column 1 of A.
- .EQN 4 1 2 23
- check~|(A{52}-A{52})
- .EQN 0 45 2 10
- W~A{52}
- .EQN 1 -19 1 13
- check=?
-