Integration by the Simpson method into the R

Asked

Viewed 77 times

5

I have the electric field data in a matrix, from this data I need to use the method of Simpson in this And.

At MATLAB, I already get.

Does anyone know any package or built in R function that does this?

1 answer

3


Try the function sintegral package Bolstad2.

Example of manual:

## integrate the normal density from -3 to 3
x<-seq(-3,3,length=100)
fx<-dnorm(x)
estimate<-sintegral(x,fx)$int
true.val<-diff(pnorm(c(-3,3)))
cat(paste("Absolute error :",round(abs(estimate-true.val),7),"\n"))
cat(paste("Relative percentage error :", 100*round((abs(estimate-true.val)/true.val),6),"%\n"))

Browser other questions tagged

You are not signed in. Login or sign up in order to post.