当前位置:网站首页>[weak transient signal detection] matlab simulation of SVM detection method for weak transient signal under chaotic background

[weak transient signal detection] matlab simulation of SVM detection method for weak transient signal under chaotic background

2022-06-13 06:54:00 FPGA and MATLAB

1. Software version

matlab2015b

2. Algorithm simulation overview

Before studying the performance of the algorithm , Firstly, we need to analyze the impact of various parameters on the overall performance of the algorithm , This paper will focus on the phase space reconstruction parameters tao and m,SVM Support vector machine parameters C and . Here, the performance impact test of four parameters is carried out respectively , Firstly, the delay parameters are analyzed , The simulation results are as follows :

        It can be seen from the simulation results in the figure , As the delay time increases , The performance of the system is basically decreasing . But when the delay time is greater than 5 When , The performance has been improved to a certain extent . therefore , The relationship between this parameter and performance is not linear .

         From the picture 2 The simulation results show that , With the increase of embedding dimension , The system performance is basically gradually improved . But when the embedding dimension is greater than 3 When , The performance of the system is basically stable .

         From the picture 3 The simulation results show that , With the increase of penalty factor , The performance of the system after an improvement , When the penalty factor is greater than 50 When , The performance remains basically the same .

        From the picture 4 The simulation results show that , With the increase of kernel function parameters , The performance of the system has been gradually improved , With the increasing kernel function parameters , The improvement of system performance gradually slows down .

        From the above comparative simulation analysis of the four parameters , The influence of the four parameters on the system performance does not satisfy the linear relationship , The four parameters have a certain degree of correlation with each other , therefore , The traditional single parameter analysis method can not obtain the optimal parameter setting . In response to this question , This paper will propose a method based on PSO Optimize parameters and parameters SVM A prediction method based on GA+PSO Improved optimization algorithm and SVM Prediction method .

          First , about SVM The prediction effect of the algorithm is tested , Set four parameters manually (2,3,300.9962,2.93), And in 481 Point to 520 Add a point with an amplitude of 0.0004 Random instantaneous signal , And then use SVM Algorithm to predict , The simulation results are shown in the figure below :

 

         From the picture 5 The simulation results show that , The overall prediction error RMSE Values in 10 Of -3 Times or so , Without considering parameter optimization , By arbitrarily setting parameters , The prediction result is poor , In the above simulation results ,200 spot ,780 Wrong detection results occurred at all points , Thus mispredicting . thus it can be seen , Parameter optimization plays a decisive role in improving the prediction effect .

         From the picture 6 The simulation results show that , The overall prediction error RMSE Values in 10 Of -4 Times or so , And the influence of interference in some areas is improved , Above picture ,200 The interference signal at point has been less than 481 Point and 520 The magnitude of the point , stay 481 Point to 520 There is a large range in the area of points , It shows the existence of instantaneous weak signal , Overall speaking , adopt PSO After the optimization , The prediction performance of the system has been significantly improved .

3. Part of the source code

clc;
clear;
close all;
warning off;
addpath 'func\'
addpath 'GA_toolbox\'
addpath 'func_SVM_toolbox\'
addpath 'func_SVM_toolbox\java\'
addpath 'func_SVM_toolbox\java\libsvm\'
addpath 'func_SVM_toolbox\matlab\'
addpath 'func_SVM_toolbox\matlab-implement[by faruto]\'
addpath 'func_SVM_toolbox\python\'
addpath 'func_SVM_toolbox\svm-toy\'
addpath 'func_SVM_toolbox\tools\'
addpath 'func_SVM_toolbox\windows\'
% As a contrast , Directly through SVM Algorithm , The simulation of the algorithm is not carried out directly through the optimization algorithm ;
rng(1);

% Optimize first , Set up 1, Then set the 2, Call the optimization value to test 
SEL = 2;
 



% Import data 
load  Training \X_train.mat;
load  test \X_test.mat;

X_train0 = X_train;
X_test0  = X_test;

 
figure;
plot(X_test0);
xlabel(' Sample points n');
ylabel(' amplitude ');

 
[y1,input1ps] = mapminmax(X_train0');
[y2,input2ps] = mapminmax(X_test0');
X_train       = y1';
X_test        = y2';
 

if SEL == 1

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% adopt GA-PSO Search for the optimal four parameters 
%tao The scope of the 
min1 = 1;
max1 = 10;
%m The scope of the 
min2 = 1;
max2 = 10;
%C The scope of the 
min3 = 1;
max3 = 1000;
%gamma The scope of the 
min4 = 0;
max4 = 5; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wmax = 0.9;
wmin = 0.1;
c1   = 2.5;
c2   = 2.5;
% Range of speed 
vmin =-7;
vmax = 7;


MAXGEN = 50;
NIND   = 10;

Chrom  = crtbp(NIND,4*10);
% The interval of variables 
Areas  = [min1,min2,min3,min4;
          max1,max2,max3,max4];


FieldD = [rep([10],[1,4]);Areas;rep([0;0;0;0],[1,4])];


Data1 = zeros(NIND,4);
gen   = 0;

for a=1:1:NIND 
    % Make sure each value is different ,
    Data1(a,:) = [1,1,1000,0.3];      
    tao        = Data1(a,1);
    m          = Data1(a,2);
    C          = Data1(a,3);
    gamma      = Data1(a,4);
    % Calculate the corresponding target value 
    [epls,tao,m,C,gamma] = func_fitness(X_train,X_test,tao,m,C,gamma);
    E          = epls;
    J(a,1)     = E;
    va(a)   =(vmax-vmin)*rand(1)+vmin;
    vb(a)   =(vmax-vmin)*rand(1)+vmin;
    vc(a)   =(vmax-vmin)*rand(1)+vmin;
    vd(a)   =(vmax-vmin)*rand(1)+vmin;   
end
[V,I] = min(J);
JI      = I;
tmpps   = Data1(JI,:);
taos    = round(tmpps(1));
ms      = round(tmpps(2));
Cs      = tmpps(3);
gammas  = tmpps(4);

Objv  = (J+eps);
gen   = 0; 

while gen < MAXGEN;   
      gen
      w       = wmax-gen*(wmax-wmin)/MAXGEN;
      FitnV = ranking(Objv);    
      Selch = select('sus',Chrom,FitnV);    
      Selch = recombin('xovsp',Selch,0.9);   
      Selch = mut(Selch,0.1);   
      phen1 = bs2rv(Selch,FieldD);   
      % Particle swarm based velocity update 
      for i=1:1:NIND
          if gen > 1
              va(i)  = w*va(i) + c1*rand(1)*(phen1(i,1)-taos2)   + c2*rand(1)*(taos-taos2);
              vb(i)  = w*vb(i) + c1*rand(1)*(phen1(i,2)-ms2)     + c2*rand(1)*(ms-ms2);
              vc(i)  = w*vc(i) + c1*rand(1)*(phen1(i,3)-Cs2)     + c2*rand(1)*(Cs-Cs2);
              vd(i)  = w*vd(i) + c1*rand(1)*(phen1(i,4)-gammas2) + c2*rand(1)*(gammas-gammas2);
          else
              va(i)  = 0;
              vb(i)  = 0;
              vc(i)  = 0;
              vd(i)  = 0;
          end
      end
      
      for a=1:1:NIND  
          Data1(a,:) = phen1(a,:);      
          tao        = round(Data1(a,1) + 0.15*va(i));% inheritance +PSO
          m          = round(Data1(a,2) + 0.15*vb(i));
          C          = Data1(a,3)       + 0.15*vc(i);
          gamma      = Data1(a,4)       + 0.15*vd(i);
          
            if tao >= max1
               tao  = max1;
            end
            if tao <= min1
               tao  = min1;
            end     
            if m >= max2
               m = max2;
            end
            if m <= min2
               m = min2;
            end  
            if C >= max3
               C = max3;
            end
            if C <= min3
               C = min3;
            end  
            if gamma >= max4
               gamma = max4;
            end
            if gamma <= min4
               gamma = min4;
            end   

            
          % Calculate the corresponding target value 
          [epls,tao,m,C,gamma] = func_fitness(X_train,X_test,tao,m,C,gamma);
          E                    = epls;
          JJ(a,1)              = E;
      end 
      
      Objvsel=(JJ);    
      [Chrom,Objv]=reins(Chrom,Selch,1,1,Objv,Objvsel);   
      gen=gen+1; 

      % Save the parameter convergence process, error convergence process and function value fitting conclusion 
      Error(gen) = mean(JJ);
      pause(0.2);
      [V,I] = min(Objvsel);
      JI      = I;
      tmpps    = Data1(JI,:);
      taos2    = round(tmpps(1));
      ms2      = round(tmpps(2));
      Cs2      = tmpps(3);
      gammas2  = tmpps(4);
end 
 
[V,I] = min(Objvsel);
JI      = I;
tmpps   = Data1(JI,:);
tao0    = round(tmpps(1));
m0      = round(tmpps(2));
C0      = tmpps(3);
gamma0  = tmpps(4);

 
save GAPSO.mat tao0 m0 C0 gamma0
end




if SEL == 2
load GAPSO.mat
% Call the four optimal parameters 
tao   = tao0;
m     = m0;
C     = C0;
gamma = gamma0;



% Advanced phase space reconstruction 
[Xn ,dn ] = func_CC(X_train,tao,m);
[Xn1,dn1] = func_CC(X_test,tao,m);

t  = 1/1:1/1:length(dn1)/1;
f  = 0.05;
sn = 0.0002*sin(2*pi*f*t);
% superposition 
dn1 = dn1 + sn';
 
%SVM Training % Make a one-step prediction 
cmd = ['-s 3',' -t 2',[' -c ', num2str(C)],[' -g ',num2str(gamma)],' -p 0.000001']; 
model = svmtrain(dn,Xn,cmd);
%SVM forecast 
[Predict1,error1] = svmpredict(dn1,Xn1,model);
RMSE              = sqrt(sum((dn1-Predict1).^2)/length(Predict1));
Err               = dn1-Predict1;
% Error acquisition 
clc;
RMSE 
 





figure;
plot(Err,'b');
title(' Prediction error of chaotic background signal '); 
xlabel(' Sample points n');
ylabel(' Error amplitude ');

Fs = 1;
y  = fftshift(abs(fft(Err)));
N  = length(y)
fc = [-N/2+1:N/2]/N*Fs;

figure;
plot(fc(N/2+2:N),y(N/2+2:N));
xlabel(' Normalized frequency ');
ylabel(' spectrum ');
text(0.06,0.07,'f=0.05Hz');

end

4. reference

[1] Zhengshengli . Research on weak signal detection method under chaotic background based on phase space reconstruction [D]. Nanjing University of Information Engineering , 2015.A07-06

原网站

版权声明
本文为[FPGA and MATLAB]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130640269006.html