Quartz | Level 8

## can we extend the trapezoidal rule to cover bivariate pdf

Hi Rick,

I saw the code below written by you.  I wounder if there is an extension to cover a bivariate case f(x,y)

```start TrapIntegral(x,y);
N = nrow(x);
dx    =   x[2:N] - x[1:N-1];
meanY = ( y[2:N] + y[1:N-1] )/2;
return( dx` * meanY );
finish;```

Thank you

Majdi

6 REPLIES 6
SAS Super FREQ

## Re: can we extend the trapezoidal rule to cover bivariate pdf

Yes, but you have to work with triangles instead of rectangles.

The trapezoidal rule is a piecewise linear method that approximates the area under a 1-D curve on [a,b] by using the function evaluated at the endpoints. You use the two endpoints because "two points determine a line."

For the volume under a surface, you can use the fact that "three points determine a plane." Chop the domain of integration into triangles and approximate the volume under the surface on each triangle ABC as the volume under the plane defined by f(A), f(B), and F(C).

If the domain is polygonal, you can always decompose it exactly into a union of triangles. For nonpolygonal domains (for example, a surface), you can approximate the regions to arbitrary closeness by using triangles.

Quartz | Level 8

## Re: can we extend the trapezoidal rule to cover bivariate pdf

Hi Rick,

Thank you for the reply. I am kind of lost her.

Have you posted any code that is similar to this case. I may look at it and try to mimic it for my pdf.

Thank you

Salah

SAS Super FREQ

## Re: can we extend the trapezoidal rule to cover bivariate pdf

No, I have not posted any code. If you have a PDF, I suggest that you use more careful integration techniques. A crude linear approximation will not be an efficient way to compute probabilities.

What is the name (or formula) for your bivariate pdf?

Quartz | Level 8

## Re: can we extend the trapezoidal rule to cover bivariate pdf

It is  bivariate Lomax distribution (see attachment).

Thank you

SAS Super FREQ

## Re: can we extend the trapezoidal rule to cover bivariate pdf

It seems to me that this function has an exact integral, so you don't need to use numerical methods at all. Just integrate w/r/t x from 0 to s and then integrate y from 0 to t to get an analytic expression for the bivariate CDF.

Quartz | Level 8

Thank you

From The DO Loop