I have given a set of X, Y coordinate and I need to find the AUC using trapezoidal formula, without using any numpy or sklearn library.
(x0,y0) is always (0,0)
(xn,yn) is always (1,1)
Below diagram
Without using any sklearn library, I understand I need to find below
hi = ?
wi= ?
AUC = sum (hi * wi)
Now I am not sure how to find hi, wi. I don't think I have all the necessary data to do the high school math. Am I missing something?
The area below (x1, y1)
and (x2, y2)
(as below vertically, not "diagonaly" like you seem to try to calculate) is simply:
(x2 - x1) * (y1 + y2) / 2
You can then generalize to other consecutive indices and add all the terms with a for
loop.
Normally AUC contains the area of the bottom right half (below your red dashed line) but if you need to take that off, just subtract 1/2
to your final result.
And you might also need to consider the edge case... not sure how you are supposed to consider before the sections between 0
and x0
and between xn
and 1
...