[R] Why two curves and numerical integration look so different?
C W
tmrsg11 at gmail.com
Thu Feb 11 03:37:18 CET 2016
Dear R,
I am graphing the following normal density curve. Why does it look so
different?
# the curves
x <- seq(-2, 4, by=0.00001)
curve(dnorm(x, 2, 10^(-100)), -4, 4) #right answer
curve(dnorm(x, 2, 10^(-100)), -3, 4) #changed -4 to -3, I get wrong answer
Why the second curve is flat? I just changed it from -4 to -3. There is
no density in that region.
Also, I am doing numerical integration. Why are they so different?
> x <- seq(-2, 4, by=0.00001)
> sum(x*dnorm(x, 2, 10^(-100)))*0.00001
[1] 7.978846e+94
> x <- seq(-1, 4, by=0.00001) #changed -2 to -1
> sum(x*dnorm(x, 2, 10^(-100)))*0.00001
[1] 0
What is going here? What a I doing wrong?
Thanks so much!
[[alternative HTML version deleted]]
More information about the R-help
mailing list