comparison rDiff/src/locfit/m/spence15.m @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0f80a5141704
1 function yhat=spence15(y)
2 % function for Spencer's 15-point graduation rule.
3 % set out following Spencer's hand-calculation method,
4 % which isn't the shortest computer program!
5
6 osev = ones(7,1);
7 n = length(y);
8 y = [ osev*y(1); y; osev*y(n) ];
9
10 n = length(y);
11 k = 3:(n-2);
12 a3 = y(k-1) + y(k) + y(k+1);
13 a2 = y(k-2) + y(k+2);
14 y1 = y(k)+3*(a3-a2);
15
16 n = length(y1);
17 k = 1:(n-3);
18 y2 = y1(k)+y1(k+1)+y1(k+2)+y1(k+3);
19
20 n = length(y2);
21 k = 1:(n-3);
22 y3 = y2(k)+y2(k+1)+y2(k+2)+y2(k+3);
23
24 n = length(y3);
25 k = 1:(n-4);
26 y4 = y3(k)+y3(k+1)+y3(k+2)+y3(k+3)+y3(k+4);
27
28 yhat = y4/320;
29 return;