This question might be a bit naive.
According to theory the mean value of a r.v. is the sum of the value times the pdf.
I try to test this in R. I am using the following code:
x<- rnorm(10000, mean=3, sd=1)
hx<-dnorm(x)
mean(x) ## this gives me a value very close to 3 as expected
sum(x*hx)/10000 ## this gives me 0.04
Why i don't get close to 3 when i run the last line of code? Am I missing something?
Thank you!