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;
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.
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?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.