Open paroussisc opened 5 years ago
Using
we get:
f_x(x) = dnorm(exp(x))*exp(x)
We compare simulated rvs to the analytical pdf using this code:
library(ggplot2)
library(distr)
mu <- 13
sd <- 1.3
transformed_pdf <- function(x)
{
return(dnorm(exp(x), mu, sd) * exp(x))
}
z <- rnorm(10000, mu, sd)
x <- data.frame(x = log(z))
ggplot(x, aes(x = x)) + geom_density(color = "blue", alpha = 0.25) + stat_function(data = data.frame(x = c(2.4, 2.7)),
color = "red",
aes(x),
fun = transformed_pdf)
And it looks like the analytical solution is correct:
Of course, taking the log of a Gaussian isn't the best idea, but there shouldn't be any negative values to take the log of due to the relatively high mean and low variance.
This issue is looking at the transformation of a Gaussian rv
Z
. HereX
= log(Z
).