Npontos = 100000; X = rand(1,Npontos); %Npontos amostras de uma VA U[0,1] %Transformação monotônica Y1 = 2*X-1; %Transformação não monotônica Y2 = X.^2; %Geração da VA de Rayleigh com a=0 e b = 1 a = 0; b = 1; YRay= a+sqrt(-b*log(1-X)); %Histogramas subplot(221); hX = histogram(X,'Normalization','pdf'); hold on; plot([0 1],[1 1],'LineWidth',3); hold off; title ('X'); xlabel('y'); ylabel('f_Y(y)'); grid; subplot(222); hY1 = histogram(Y1,'Normalization','pdf'); hold on; plot([-1 1],[1/2 1/2],'LineWidth',3); hold off; grid; title ('Y=Y=2X-1'); xlabel('y'); ylabel('f_Y(y)'); subplot(223); hY2 = histogram(Y2,'Normalization','pdf'); hold on; y = linspace(0,1,1000); plot(y, 1./(2*sqrt(y)),'LineWidth',3); hold off; grid; title ('Y = X^2'); xlabel('y'); ylabel('f_Y(y)'); subplot(224); hYRay = histogram(YRay,'Normalization','pdf'); hold on; y = linspace(a,10,1000); plot(y, 2/b*(y-a).*exp(-(y-a).^2/b),'LineWidth',3); hold off; grid; title ('Y - VA Rayleigh'); xlabel('y'); ylabel('f_Y(y)');