Advertisement
Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.71 KB | None | 0 0
  1. # МС_ЛР_1_АЛЕКНА
  2.  
  3. V = 23;
  4. n = 5 + mod(V, 16);
  5. p = 0.1 + 0.01 * V;
  6. lambda = 0.5 + 0.1 * V;
  7.  
  8. x = binornd(n, p, [1 200]);
  9. x = sort(x);
  10.  
  11. #statistic series
  12. stats = statseries(x, 200);
  13.  
  14. #plot(stats(1, :), stats(3, :))
  15.  
  16. axis([stats(1,1), stats(1, end), 0, 1]);
  17. plot(stats(1, :), cumsum(stats(3, :)))
  18.  
  19.  
  20.  
  21. -------------------------------------
  22.  
  23. function y = statseries(x, size)
  24.  
  25.   stats = [x(1); 1];
  26.   cur = 1;
  27.   for i = 2 : size
  28.    
  29.     if (x(i) == stats(1, cur))
  30.       stats(2, cur) = stats(2, cur) + 1;
  31.     else
  32.       cur = cur + 1;
  33.       stats = [stats, [x(i); 1]];
  34.     endif
  35.   end
  36.  
  37.   w = stats(2, :) / sum(stats(2, :));
  38.   stats(3, :) = w;
  39.   y = stats;
  40.  
  41. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement