powered by
Calculate the area under the curve (AUC) using the trapezoid method.
trapezoid_auc(x, y)
A numeric value of the area under the curve
A numeric vector of x values
A numeric vector of y values
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