Professional Documents
Culture Documents
Linear LSA: % Original Observations
Linear LSA: % Original Observations
........................................................................................................................................ 1
Linear LSA ........................................................................................................................ 1
General LSA ...................................................................................................................... 1
Global Test (alpha = 0.05) .................................................................................................... 3
clc;
clear all;
Linear LSA
xyz = dlmread('data1.txt','',0,1);
x = xyz(:,1);
y = xyz(:,2);
z = xyz(:,3);
for i = 1:16
B(i,1:4) = [-1 -x(i) -y(i) -x(i)*y(i)];
f(i,1) = -z(i);
end
W = eye(16);
Delta = (inv(B'*W*B))*(B'*W*f);
residuals = f - (B*Delta);
fprintf('\n\nInitial Parameter Approximations:\na0 = %f; a1 = %f; a2 =
%f; a3 = %f\n',Delta);
General LSA
n = 48; n0 = 36; r = 12; u = 4; c = 16;
fprintf('GLS Counting:\nn = %d; n0 = %d; r = %d; u = %d; c = %d
\n',n,n0,r,u,c);
A = zeros(c,n);
B = zeros(c,u);
% Original observations
l = [];
for i = 1:c
l = [l; x(i); y(i); z(i)];
end
% Initial approximations
l0 = l;
x0 = Delta;
sigma0 = 0.1;
W = eye(n);
niter = 0;
1
while (abs(Delta) >= 1e-8)
a0 = x0(1); a1 = x0(2); a2 = x0(3); a3 = x0(4);
x = l0(1:3:3*c-2);
y = l0(2:3:3*c-1);
z = l0(3:3:3*c);
% GLS Adjustment
Q = inv(W);
Qe = A*Q*A';
We = inv(Qe);
Delta = inv(B'*We*B)*B'*We*f;
K = We*(f-B*Delta);
v = Q*A'*K;
if (niter == 0)
fprintf('\n\n"A" Matrix (Block Diagonal Elements of each row)
for 1st iteration:\n');
for row = 1:c
fprintf(' %9.4f %9.4f %9.4f
\n',A(row,3*row-2:3*row));
end
fprintf('\n\n"B" Matrix for 1st iteration:\n');
fprintf(' %d %9.4f %9.4f %9.4f\n',B');
end
2
fprintf('\n\nFinal residuals:\n-----|v_x|--------|v_y|--------|
v_z|-----\n');
fprintf(' %9.6f %9.6f %9.6f\n',v);
fprintf('\n\n\n\n\nAdjusted observations:\n-----|x|----------|
y|----------|z|-----\n');
fprintf(' %9.6f %9.6f %9.6f\n',l0);
ts = v'*W*v/(sigma0^2);
"A" Matrix (Block Diagonal Elements of each row) for 1st iteration:
-0.1979 -0.2776 1.0000
-0.2023 -0.3002 1.0000
-0.2030 -0.3226 1.0000
-0.1939 -0.3506 1.0000
-0.2161 -0.2724 1.0000
-0.2195 -0.2972 1.0000
-0.2239 -0.3235 1.0000
-0.2239 -0.3496 1.0000
-0.2434 -0.2734 1.0000
-0.2488 -0.2970 1.0000
-0.2434 -0.3255 1.0000
-0.2522 -0.3494 1.0000
-0.2714 -0.2803 1.0000
-0.2702 -0.3046 1.0000
3
-0.2724 -0.3282 1.0000
-0.2699 -0.3501 1.0000
Iteration No. 1
Delta:
0.000910487
-0.000315134
0.000125921
-0.000021365
Iteration No. 2
Delta:
0.003263626
-0.002058383
-0.001770360
0.000822017
Iteration No. 3
Delta:
-0.000023684
0.000004783
0.000015712
-0.000003901
Iteration No. 4
Delta:
0.000055583
4
-0.000020586
-0.000018913
0.000006702
Iteration No. 5
Delta:
-0.000000193
0.000000041
0.000000150
-0.000000039
Iteration No. 6
Delta:
0.000000444
-0.000000152
-0.000000140
0.000000047
Iteration No. 7
Delta:
-0.000000001
0.000000000
0.000000001
-0.000000000
Final residuals:
-----|v_x|--------|v_y|--------|v_z|-----
0.006158 0.008669 -0.031214
-0.000114 -0.000170 0.000565
-0.021790 -0.034979 0.108129
0.014333 0.026151 -0.074007
0.004772 0.006017 -0.022092
-0.004815 -0.006540 0.021963
-0.018990 -0.027604 0.085044
0.000823 0.001293 -0.003672
0.007065 0.007909 -0.028924
-0.001510 -0.001800 0.006049
0.028425 0.038031 -0.116011
-0.005952 -0.008271 0.023525
0.005887 0.006046 -0.021552
-0.004688 -0.005272 0.017261
-0.032470 -0.039135 0.118926
5
0.022865 0.029655 -0.083991
Adjusted observations:
-----|x|----------|y|----------|z|-----
2.086158 2.008669 6.138786
2.999886 2.179830 6.370565
3.888210 2.175021 6.548129
5.064333 1.866151 6.675993
1.874772 2.746017 6.297908
2.875185 2.873460 6.551963
3.931010 3.032396 6.835044
5.010823 3.061293 7.086328
1.917065 3.857909 6.611076
2.868490 4.068200 6.906049
4.058425 3.888031 7.143989
4.994048 4.201729 7.483525
2.195887 4.996046 6.998448
3.175312 4.934728 7.247261
4.107530 4.990865 7.518926
5.052865 4.959655 7.766009
Hypothesis is accepted!!
----|cv1|-------|ts|-------|cv2|----
4.4038 7.3741 23.3367