Transcription of Use R to Compute Numerical Integrals
{{id}} {{{paragraph}}}
Stat401: Introduction to ProbabilityHandout-08, November 2, 2011 Use R to Compute Numerical IntegralsIn short, you may use R to nd out a Numerical answer to ann-fold integrate a one-dimensional integral over a nite or in nite interval, use R functionintegrate. For example, nd out 101(x+ 1)pxdx>## define the integrated function>integrand <- function(x) {1/((x+1)*sqrt(x))}>## integrate the function from 0 to infinity>integrate(integrand, lower = 0, upper = Inf) with absolute error < Numerical answer is 3:141593 up to a small error 2:7 10 example is to nd out 1:96 1:961p2 e x22dx>f <- function(x) {1/sqrt(2*pi)*exp(-x^2/2)}>integrate(f, lower = , upper = ) with absolute error < more information about the functionintegrate, typehelp(integrate)in integrate a scalar function over a multidimensional rectangle, use R useadaptIntegrate, you need to install the R packagecubature rst:(1)Download the package le \ " (2)Install the packagecubaturein R.
Stat401: Introduction to Probability Handout-08, November 2, 2011 Use R to Compute Numerical Integrals In short, you may use R to nd out a numerical answer to an n-fold integral. I.
Domain:
Source:
Link to this page:
Please notify us if you found a problem with this document:
{{id}} {{{paragraph}}}