BookmarkSubscribeRSS Feed
Salah
Quartz | Level 8

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
Rick_SAS
SAS Super FREQ

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.

Salah
Quartz | Level 8

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

Rick_SAS
SAS Super FREQ

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?

Salah
Quartz | Level 8

It is  bivariate Lomax distribution (see attachment).

 

Thank you

Rick_SAS
SAS Super FREQ

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 6 replies
  • 1135 views
  • 1 like
  • 2 in conversation