trap_roc: Calculate Area Under Curve (AUC) using trapezoidal rule
Description
Computes the area under a curve using the trapezoidal rule of numerical integration.
Usage
trap_roc(x, y)
Value
A numerical value representing the computed area under the curve as a double precision value.
Arguments
x
Numeric vector (arma::vec) of x-coordinates (should be sorted in increasing order)
y
Numeric vector (arma::vec) of y-coordinates corresponding to x-coordinates
Details
The trapezoidal rule approximates the area under the curve by dividing it into trapezoids.
For each pair of adjacent points (x[i], y[i]) and (x[i+1], y[i+1]), it calculates the area of the trapezoid formed.
The total AUC is the sum of all these individual trapezoid areas.
Special cases:
- Returns 0 if there are fewer than 2 points (no area can be calculated)
- Handles both increasing and decreasing x values (though typically x should be increasing for ROC curves)