Learn R Programming

YEAB (version 1.0.6)

trapezoid_auc: Area under the curve (AUC)

Description

Calculate the area under the curve (AUC) using the trapezoid method.

Usage

trapezoid_auc(x, y)

Value

A numeric value of the area under the curve

Arguments

x

A numeric vector of x values

y

A numeric vector of y values

Examples

Run this code
x_values <- c(0, 1, 2, 3, 4) # Delay times
y_values <- c(1, 0.8, 0.6, 0.4, 0.2) # Discounted values
auc_result <- trapezoid_auc(x_values, y_values)
print(paste("Area Under Curve: ", auc_result))

Run the code above in your browser using DataLab