powered by
Computes the integration for a real-valued function.
simpson(fun, lb, ub, N = 100)
Integrand expression
Lower bound of integration.
Upper bound of integration.
An even integer value indicating the number of subdivisions for applying Simpson's integration method.
E. Suli and D. Mayers 2003. An Introduction to Numerical Analysis, Cambridge University Press.
# NOT RUN { fun <- function(x) 1/sqrt( 2*pi*sigma^2 )*exp( -.5*(x-mu)^2/sigma^2 ) mu <- 0 sigma <- 1 lb <- 0 ub <- Inf N <- 100 simpson(fun = fun, lb = lb, ub = ub, N = N) # }
Run the code above in your browser using DataLab