PMDcoeff = 0.1 * ( 1e-12 / sqrt(1e3) ); %PMD s/sqrt(m) L_40 = 40e3; %m mean_dgd = PMDcoeff * sqrt(L_40); % in sec. E(tau) == PMD value disp(['defined mean of DGD in pico seconds: ',num2str(mean_dgd*1e12)]); dgd_40km = []; for i = 1:4000 dgd_40km(i,:) = getDGDrealization(mean_dgd,1); end disp(['simulated mean of DGD in pico seconds: ',num2str(mean(dgd_40km)*1e12)]); %%% 2 test for segmented link %%%% L_10 = 10e3; %m mean_dgd = PMDcoeff * sqrt(L_10); % in sec. E(tau) == PMD value dgd_10km = []; for j = 1:4 for i = 1:1000 dgd_10km(i,j) = getDGDrealization(mean_dgd,1); end end a = sum(dgd_10km,2) ; %%% calc maxwell curve mean_dgd = PMDcoeff * sqrt(L_40) * 1e12 ; % in sec. q = sqrt(pi/8) * mean_dgd; t = [0:0.01:100]; maxwell = sqrt(2/pi).* (t.^2)/(q.^3) .* exp(-t.^2/(2*q^2)) ; %%% plot everything figure; histogram(dgd_40km*1e12,1000,"Normalization","pdf",'EdgeColor','none','FaceColor','b','FaceAlpha',0.6); hold on histogram(a*1e12,1000,"Normalization","pdf",'EdgeColor','none','FaceColor','g','FaceAlpha',0.6); plot(t(1:200),maxwell(1:200),'r','LineWidth',3); xline(mean_dgd,'LineWidth',3,'Color','magenta') hold off function z = getDGDrealization(mean_dgd,N) mean_dgd = mean_dgd; %to pico seconds q = sqrt(pi/8) * mean_dgd; threenormaldists = randn(3,N)*q; %3x normal dist around [-1,1] with a deviation of mean_dgd y = threenormaldists.^2; z = sqrt(sum(y,1)); end