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 auc.xy.numeric

y,x

A pair of <double> vectors of length n.

method

A <integer> value (default: 0). Defines the underlying method of calculating the area under the curve. If 0 it is calculated using the trapezoid-method, if 1 it is calculated using the step-method.

presorted

A <logical>-value length 1 (default: FALSE). If TRUE the input will not be sorted by threshold.

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].


[Package SLmetrics version 0.3-4 Index]