Inserindo densidade no histograma associado

Probabilidade: Função de VA’s Contínuas x~Exp(1) y = ln(x)

fY(y)= ?

# Gerando exponencial com n=10.000 e lambida =1
x<-rexp(10000,1)

# Tomando o log desses valores
x<-log(x)


eq<-function(y){exp(y-exp(y))}


#eq<-{exp(y-exp(y))}

plot(x,eq(x))

h<-hist(x,breaks=10,col="red")

xfit<-seq(min(x),max(x),length=40)
yfit<-eq(xfit) 
yfit <- yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

```

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.