Matlab functions    from  BioméCardio    

 
   clinspace
dctn   

cumsimps

Cumulative Simpson's numerical integration

Contents

Download

cumsimps.m

Syntax

   z = cumsimps(y)
   z = cumsimps(x,y)
   z = cumsimps(...,dim)

Description

z = cumsimps(y) computes an approximation of the cumulative integral of y via the Simpson's rule (with unit spacing). To compute the integral for spacing different from one, multiply z by the spacing increment.

For vectors, cumsimps(y) is a vector containing the cumulative integral of y. For matrices, cumsimps(y) is a matrix the same size as x with the cumulative integral over each column. For N-D arrays, cumsimps(y) works along the first non-singleton dimension.

z = cumsimps(x,y) computes the cumulative integral of y with respect to x using the Simpson's method. x and y must be vectors of the same length, or x must be a column vector and y an array whose first non-singleton dimension is length(x). cumsimps operates across this dimension.

z = cumsimps(x,y,dim) or cumsimps(y,dim) integrates along dimension dim of y. The length of x must be the same as size(y,dim).

Examples

Let us define by pdf the following probability density function of a normal distribution:

The exact related cumulative density function is given by:

Let us compare cumsimps(x,pdf) with cdf with mean = 0, variance = 1 and x = -5:0.5:5

mu = 0; sigma = 1;
x = -5:0.5:5;
pdf = 1/sqrt(2*pi)*exp(-(x-mu).^2/2/sigma^2);
cdf = 0.5*(1+erf((x-mu)/sigma/sqrt(2)));
plot(x,cumsimps(x,pdf),x,cdf,'o')

This example uses two complex inputs:

z = exp(1i*pi*(0:100)/100);
ct = cumtrapz(z,1./z);
ct(end)
ans =

   0.0000 + 3.1411i

See also

simps, cumtrapz

About the author

Damien Garcia, Eng., Ph.D.
Assistant professor, Department of radiology
CRCHUM, University of Montreal Hospital
Montreal, QC, Canada
Damien.Garcia.REMOVE-THIS@BiomeCardio.com

www.biomecardio.com