I have the electric field data in an array, from this data I need to use the method of Simpson in this E .
In MATLAB, I already have it.
Does anyone know of any package or built-in R function that does this?
I have the electric field data in an array, from this data I need to use the method of Simpson in this E .
In MATLAB, I already have it.
Does anyone know of any package or built-in R function that does this?
Try the sintegral
function of the 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"))