编辑代码

set.seed(123)
model<-function(){
    y=c()
x=seq(0.5,10,0.5)
y=50+10*x+rnorm(n=20,mean=0,sd=4)
return (y)
}
#model()
Y=c()
for (i in c(1:500)){
    Y=cbind(Y,model())
}
x=seq(0.5,10,0.5)
#df=data.frame(y=Y[,1],x=x)
coefs=data.frame()
df=data.frame()

for(i in c(1:500)){
    
    coefs=rbind(coefs,coef(lm(Y[,i]~x)))
}

print(hist(coefs[,1]))