MSE Mean Square Error of clock offset and clock skew not decreasing smoothly

1 view (last 30 days)
I am estimating clock offset and clock skew of Pairwise Broadcast Synchronization using Truncated Levy distributed random delays. The MSE Mean Square Error is not decreasing as it should. What are the changes in the values I can do to get the result?
%The code below solves two equations. The initial part of the code generates 100 values of random data U,V,x_0,y_0 which are seed values for fsolve
clc
clear all
close all
c=4;
d=10^-4;
alpha=1;
n=100;
%Generating 100 values of Gaussian distributed random delay in the range
%5*10^-3 and 6*10^-3
a=5*10^-3;
b=6*10^-3;
X = (b-a).*randn(1,n) + a;
X1 = X;
%Generating T_1_i_A(:,1)
a=0.005;
b=5;
x = (b-a).*rand(1,n)+a;
T_1_i_A=zeros(n,30);
T_1_i_A(:,1)=transpose(x);
%Generating T_1_i_A for N=2:30 where N is no. of rounds of message exchange
for j=2:30
T_1_i_A(:,j)=T_1_i_A(:,j-1)+X(j);
end
%Generating T_2_i_B and T_2_i_P from T_1_i_A,d,X
T_2_i_B=zeros(n,30);
for j=1:30
T_2_i_B(:,j)=T_1_i_A(:,j)+20*10^-3+2.01*(T_1_i_A(:,j)-T_1_i_A(:,1))+15*10^-4+transpose(X);
end
T_2_i_P=zeros(n,30);
for j=1:30
T_2_i_P(:,j)=T_1_i_A(:,j)+10*10^-3+1.01*(T_1_i_A(:,j)-T_1_i_A(:,1))+5*10^-4+transpose(X1);
end
%finding U and V
U=T_2_i_P-T_2_i_B;
V=T_1_i_A-T_1_i_A(:,1);
fun = @root2d;
%Generating 100 random values of pre-defined clock offset in the range
%-10*10^-3 and 10*10^-3
a=-10*10^-3;
b=10*10^-3;
x_0 = (b-a).*rand(1,n) + a;
%Generating 100 random values of pre-defined clock skew in the range
%0.99 and 1.01
a1=0.99;
b1=1.01;
y_0=(b1-a1).*rand(1,n)+a1;
x0=zeros(2,n);
for i=1:n
x0(:,i)=[x_0(i); y_0(i)];
end
options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective');
maxN = 30;
x = zeros(size(x0,1), n, maxN);
for N=5:maxN
for i=1:n
x(:,i,N)= lsqnonlin(@(x)root2d(x, U(i,N),V(i,N),N,c,d,alpha), x0(:,i),[-10*10^-3;0.99],[10*10^-3;1.01], options);
end
mse_theta_offset_hat_final(N)=mse(x(1,:,N),x_0);
mse_theta_skew_hat_final(N)=mse(x(2,:,N),y_0);
end
%Plots
k=5:30;
subplot(2,1,1),plot(k,mse_theta_offset_hat_final(5:30),'r+-')
title('clock offset')
xlabel('No. of Observations')
ylabel('MSE')
grid on
subplot(2,1,2),plot(k,mse_theta_skew_hat_final(5:30),'-*')
title('clock skew')
xlabel('No. of Observations')
ylabel('MSE')
grid on
function f = root2d(x, U, V, N,c,d,alpha)
f(1)=(1.5./(U-x(1)-x(2)*V+d)-(c/2)./(U-x(1)-x(2)*V+d).^2)*N+alpha*sum(1:N);
f(2)=((1.5*V)./(U-x(1)-x(2)*+d)-(c/2)*V./(U-x(1)-x(2)*V+d).^2+alpha*V)*N;
end

Answers (1)

Debadipto
Debadipto on 31 Aug 2023
Hello @Siva,
I understand you’re trying to estimate the clock offset and clock skew of Pairwise Broadcast Synchronization using Truncated Levy distributed random delays. However, the mean square error is not decreasing as expected, and so you’re seeking changes to improve the results.
To improve the results and decrease the MSE, you can try the following changes:
  1. Modify the optimization options: You can experiment with different optimization options to improve the convergence of the ‘lsqnonlin’ function. Try changing the line options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective') to options = optimoptions(@lsqnonlin,'Algorithm','levenberg-marquardt') or options = optimoptions(@lsqnonlin,'Algorithm','sqp').
  2. Increase the number of random data points: You can increase the number of random data points to get a larger sample size and potentially improve the estimation accuracy. Modify the line ‘n = 100’ to a higher value, such as ‘n = 500’ or ‘n = 1000’.
  3. Adjust the range of random clock offset values: The code generates random clock offset values between -1010^-3 and 1010^-3. You can try narrowing down this range to focus on values closer to the expected offset. Modify the lines ‘a = -10*10^-3’ and ‘b = 10*10^-3‘ to smaller values, such as ‘a = -5*10^-3’ and ‘b = 5*10^-3’.
  4. Adjust the random clock skew values range: The code generates random clock skew values between 0.99 and 1.01. You can try narrowing down this range to focus on values closer to the expected skew. Modify the lines ‘a1 = 0.99’ and ‘b1 = 1.01’ to smaller values, such as ‘a1 = 0.995’ and ‘b1 = 1.005’.

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!