#####
k<-10;
Y<-matrix(nrow=1,ncol=1000);
for(s in 1:1000){
y<-0;
for(i in 1:k){x<-rexp(1);y<-y+x};
Y[s]<-2*y}
#
Y
#
YY<-rchisq(1000,20);
#
layout(matrix(c(1:2),1, 2, byrow = TRUE));
layout.show(2);
hist(YY);
hist(Y);
######
# gerando betas: rejeicao-aceitacao
#
X<-matrix(nrow=1,ncol=1000);
for(i in 1:1000){
y<-runif(1);
u<-runif(1,0,2.67);
while(u>=dbeta(y,2.7,6.3)){y<-runif(1);u<-runif(1,0,2.67)}
X[i]<-y
}
#
layout(matrix(c(1:2),1, 2, byrow = TRUE));
layout.show(2);
hist(X);
hist(rbeta(1000,2.7,6.3));