annotate rDiff/src/locfit/m/spence21.m @ 3:29a698dc5c7e default tip

Merge multiple heads.
author Dave Bouvier <dave@bx.psu.edu>
date Mon, 27 Jan 2014 14:15:36 -0500
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 function yhat=spence21(y)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 % function for Spencer's 21-point graduation rule.
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3 % set out following Spencer's hand-calculation method,
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 % which isn't the shortest computer program!
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 oten = ones(10,1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7 n = length(y);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8 y = [ oten*y(1); y; oten*y(n) ];
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 n = length(y);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 k = 4:(n-3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
12 y1 = -y(k-3) + y(k-1) + 2*y(k) + y(k+1) -y(k+3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
13
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
14 n = length(y1);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
15 k = 4:(n-3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
16 y2 = y1(k-3)+y1(k-2)+y1(k-1)+y1(k)+y1(k+1)+y1(k+2)+y1(k+3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
17
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
18 n = length(y2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
19 k = 3:(n-2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
20 y3 = y2(k-2)+y2(k-1)+y2(k)+y2(k+1)+y2(k+2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
21
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
22 n = length(y3);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
23 k = 3:(n-2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
24 y4 = y3(k-2)+y3(k-1)+y3(k)+y3(k+1)+y3(k+2);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
25
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
26 yhat = y4/350;
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
27 return;