close all % binarna raspodela n=100000; X=randi([0,1],1,n); figure(1) subplot(2,1,1) stem(X(1:50)) title('Prvih 50 vrednosti binarne promenljive') h=histc(X,[0,1]); p=h/n MX=mean(X) VarX=var(X) DX=std(X) subplot(2,1,2) bar([0,1],p) title('Zakon raspolede') % generisanje vektora greske pe = 0.1; n=100000; x=VektorGreske(n,pe); figure(2) subplot(211) stem(x(1:20)) title('Prvih 20 vrednosti') h=hist(x,2); px=h./n; subplot(212) bar([0,1],px) title('Zakon raspodele') grid xsr = mean(x) % generisanje uniformne raspodele n=100000; u=rand(1,100000); [h,x]=hist(u,100); dx=x(2)-x(1); f=h/(n*dx); figure(3) subplot(2,1,1) plot(u) title('Vremenski prikaz slucajnog procesa sa uniformnom raspodelom') subplot(2,1,2) bar(x,f) line([0,1],[1 1],'Color','r','LineWidth',3) title('Histogram slucajnog procesa sa uniformnom raspodelom') Mu=mean(u) VarU=var(u) StdU=std(u) % Ako je potrebno generisati fY(y)=0,5*cos(y), -pi/2