I would like to calculate the following double integral, with lower bound = -Inf and upper bound = Inf for both integrals. How can I define the function value to be zero for M=0 and/or leave out the numerical integration over M=0? It is a density function and I want to define the area over M=0 as zero when calculating probabilities.
The function can be seen here:
The R code is here, where one can see the "jump" due to my problem:
mum<-5.16
mub<-1.5
mur<-2.764
sm<-3.37
sb<-0.2
sr<-0.056
dk<-function(k){
integrate(function(r) {
sapply(r, function(r) {
1/(2*pi*sr^2)^0.5*exp(-(r-mur)^2/(2*sr^2))*integrate(function(m) {1/(abs(m)*2*pi*sm*sb)*exp(-(m-mum)^2/(2*sm^2)-((k-r)/m-mub)^2/(2*sb^2))},lower=Inf, upper=Inf)$value
})
}, lower=Inf, upper=Inf)$value
}
curve(sapply(x,dk), from=-2, to=18, lwd=2,col="red")