Advertisement
cheungtifan

Untitled

Apr 25th, 2012
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.11 KB | None | 0 0
  1. % I use this code to obtain the false positive rate of the nonparametric cusum algorithm
  2. max_iter = 1000;
  3. taoval = 1:0.5:200;            %taoval means \tau, which is the threshold
  4. false_pos = zeros(size(taoval));
  5. for itao = 1:length(taoval)
  6.     tao = taoval(itao);
  7.     num = 0;
  8.     for is = 1:100 % the number of the normal data are 100
  9.         flag = 0;
  10.         Si_1 = 0;
  11.         Si1 = 0;
  12.     for i = 1:max_iter
  13.         Si1 = Si_1+0.1*abs(randn(1)); %Si1 is the the nonparametric cusum algorithm statistics, 0.1 decides the power of the attack
  14.        
  15.         if(i>100)
  16.            Si1 = Si1+0.5*94.20; %94.20 is the \gamma?percentiles of z3, which is derived from historical data. 0.5 means the true value is changed by 50%
  17.         end
  18.        
  19.        
  20.         if(Si1>tao)
  21.             flag = 1;
  22.             break;
  23.         end
  24.         Si_1 = Si1;
  25.     end
  26.     if(flag)
  27.        num = num+1;
  28.     end
  29.     end
  30.     false_pos(itao) = num/100; %false_pos(i) is the false positive rate
  31.  
  32. end
  33.  
  34. figure;
  35. plot(taoval,false_pos,'b-','linewidth',4);
  36. xlabel('\tau');
  37. ylabel('False Positive Rate');
  38. title('z_{4}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement