sintegral              package:Bolstad              R Documentation

_N_u_m_e_r_i_c_a_l _i_n_t_e_g_r_a_t_i_o_n _u_s_i_n_g _S_i_m_p_s_o_n'_s _R_u_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     Takes a vector of x values and a corresponding set of postive
     f(x)=y values and evaluates the area under the curve:

                             int{f(x)dx}

     .

_U_s_a_g_e:

             sintegral(x, fx, n.pts = 256, ret = FALSE)

_A_r_g_u_m_e_n_t_s:

       x: a sequence of x values.

      fx: the value of the function to be integrated at x.

   n.pts: the number of points to be used in the integration.

     ret: if true returns the partial sums of the integration.

_E_x_a_m_p_l_e_s:

     ## integrate the normal density from -3 to 3
     x<-seq(-3,3,length=100)
     fx<-dnorm(x)
     estimate<-sintegral(x,fx)
     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"))

