Advertisement
PavelMiridonov

Untitled

Sep 28th, 2021 (edited)
2,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.86 KB | None | 0 0
  1. sum_r = 0;
  2. N = 12;
  3. nu_0 = 0;
  4. nu = 0;
  5. t1 = 0; t2 = 0; t3 = 0; t4 = 0;
  6. function [nu_0]= Time_calc(r)
  7.     for i = 1:N
  8.         sum_r = sum_r + r;
  9.     end
  10.     nu_0 = (sum_r - N/2)/(sqrt(N/12));
  11. endfunction
  12. for i = 1:400
  13.     r = rand();
  14.     nu = (Time_calc(r))*0.6 + 3.2;
  15.     msg = 0;
  16.     if r >= 0 & r < 0.03 then t1 = t1 + 1;
  17.     msg = 1;
  18.     else if r >= 0.03 & r < 0.60 then t2 = t2 + 1;
  19.     msg = 2;
  20.     else if r >= 0.60 & r < 0.73 then t3 = t3 + 1;
  21.     msg = 3;
  22.     else t4 = t4 + 1;
  23.     msg = 4;
  24.     end;
  25.     end;
  26.     end;
  27.     printf('Рандомное число: %f Тип сообщения:%i Время???: %f \n',r,msg,nu);
  28. end
  29.     disp('____________________');
  30.     disp(t1);
  31.     disp(t2);
  32.     disp(t3);
  33.     disp(t4);
  34.     disp('____________________');
  35.     disp(t1/(400));
  36.     disp(t2/(400));
  37.     disp(t3/(400));
  38.     disp(t4/(400));
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement