auc.xy {SLmetrics} | R Documentation |
Area under the curve
Description
The auc.xy()
-function calculates the area under the curve.
Usage
## Generic S3 method
auc.xy(...)
Arguments
... |
Arguments passed on to
|
Value
A <double> value.
Definition
Trapezoidal rule
The trapezoidal rule approximates the integral of a function f(x)
between
x = a
and x = b
using trapezoids formed between consecutive points. If
we have points x_0, x_1, \ldots, x_n
(with a = x_0 < x_1 < \cdots < x_n = b
)
and corresponding function values f(x_0), f(x_1), \ldots, f(x_n)
, the area under
the curve A_T
is approximated by:
A_T \approx \sum_{k=1}^{n} \frac{f(x_{k-1}) + f(x_k)}{2} \bigl[x_k - x_{k-1}\bigr].
Step-function method
The step-function (rectangular) method uses the value of the function at one
endpoint of each subinterval to form rectangles. With the same partition
x_0, x_1, \ldots, x_n
, the rectangular approximation A_S
can be written as:
A_S \approx \sum_{k=1}^{n} f(x_{k-1}) \bigl[x_k - x_{k-1}\bigr].