[R] odd dnorm behaviour (?)
Mike Lawrence
Mike.Lawrence at DAL.CA
Tue Jul 8 06:41:37 CEST 2008
#Quick one hopefully. Shouldn't dnorm be returning the pdf? Last time
I checked,
#a probability shouldn't be greater than 1 as produced by:
curve(dnorm(x,0,.1),from=-1,to=t)
#Shouldn't I be getting an axis more like that produced by:
f=function(x,m,s){
y=rep(NA,length(x))
for(i in 1:length(x)){
y[i]=integrate(
dnorm
, upper=x[i]+sqrt(.Machine$double.eps)
, lower=x[i]-sqrt(.Machine$double.eps)
, mean=m
, sd=s
)$value
}
return(y)
}
curve(f(x,m=0,s=1),from=-5,to=5)
#If the latter code betrays a misunderstanding of what a pdf is, be
gentle!
#Mike
More information about the R-help
mailing list