Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- raspred_type = 'norm_raspr'; // ТИП РАСПРЕДЕЛЕНИЯ ЕПТА (exp | norm_raspr)
- mu = 3.2;
- sigma = 0.6;
- lambda = 0.58;
- sum_r = 0;
- N = 12;
- nu_0 = 0;
- nu = 0;
- t1 = 0; t2 = 0; t3 = 0; t4 = 0;
- function [nu_0]= Time_calc(r)
- for i = 1:N
- sum_r = sum_r + r;
- end
- nu_0 = (sum_r - N/2)/(sqrt(N/12));
- endfunction
- if (raspred_type == 'norm_raspr') then
- for i = 1:400
- r = rand();
- nu = (Time_calc(r))*sigma + mu;
- msg = 0;
- if r >= 0 & r < 0.03 then t1 = t1 + 1;
- msg = 1;
- else if r >= 0.03 & r < 0.60 then t2 = t2 + 1;
- msg = 2;
- else if r >= 0.60 & r < 0.73 then t3 = t3 + 1;
- msg = 3;
- else t4 = t4 + 1;
- msg = 4;
- end;
- end;
- end;
- printf('Рандомное число: %f Тип сообщения:%i Время???: %f \n',r,msg,nu);
- end;
- else if (raspred_type == 'exp') then
- for i = 1:400
- r = rand();
- x = (-1)*(1/lambda)*log(r);
- msg = 0;
- if r >= 0 & r < 0.03 then t1 = t1 + 1;
- msg = 1;
- else if r >= 0.03 & r < 0.60 then t2 = t2 + 1;
- msg = 2;
- else if r >= 0.60 & r < 0.73 then t3 = t3 + 1;
- msg = 3;
- else t4 = t4 + 1;
- msg = 4;
- end;
- end;
- end;
- printf('Рандомное число: %f Тип сообщения:%i Время???: %f \n',r,msg,x);
- end;
- end;
- end
- disp('____________________');
- disp(t1);
- disp(t2);
- disp(t3);
- disp(t4);
- disp('____________________');
- disp(t1/(400));
- disp(t2/(400));
- disp(t3/(400));
- disp(t4/(400));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement