View source: R/trap_MLestimates.R
trapezoidarea | R Documentation |
trapezoidarea
calculates the approximated area
under curve, using trapezoidal rule.
trapezoidarea(x, y)
x , y |
Numeric vectors of same length, representing the |
The function approximates the area bounded by the following 4 curves:
x = a, x = b, y = 0, y = f(x)
a
and b
are set at the min and max value of given x
coordinates. (x, y)
are some points on the y = f(x)
curve.
Numeric value of the area under curve approximated with trapezoid rule.
trapezoidarea
is used internally in other function(s) of ROCit.
# Area under rectangle -----------------
trapezoidarea(seq(0, 10), rep(1, 11))
# Area under triangle ------------------
trapezoidarea(seq(0, 10), seq(0, 10))
# Area under normal pdf ----------------
x_vals <- seq(-3, 3, 0.01); y_vals <- dnorm(x_vals)
trapezoidarea(x = x_vals, y = y_vals) # theoretically 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.