[R] How to double integrate a function in R
Tiago V. Pereira
tiago.pereira at mbe.bio.br
Mon Jul 29 15:42:37 CEST 2013
I would like to express my gratitude for the great help given by David and
Hans regarding my last query.
Thank you very much for your time, people.
All the best,
Tiago
---
Hello, R users!
I am trying to double integrate the following expression:
# expression
(1/(2*pi))*exp(-y2/2)*sqrt((y1/(y2-y1)))
for y2>y1>0.
I am trying the following approach
# first attempt
library(cubature)
fun <- function(x) {
(1/(2*pi))*exp(-x[2]/2)*sqrt((x[1]/(x[2]-x[1])))} adaptIntegrate(fun,
lower = c(0,0), upper =c(5, 6), tol=1e-8)
However, I don't know how to constrain the integration so that y2>y1>0.
Any ideas?
Tiago
--
Tiago V. Pereira, MSc, PhD
Center for Studies of the Human Genome
Department of Genetics and Evolutionary Biology
University of São Paulo
Rua do Matão, 277
CEP 05508-900
São Paulo - SP, Brazil
More information about the R-help
mailing list