I am trying to calculate the area under each peak in a graph that I plotted with a set of x and y co-ordinates,
I don't have a function for (x,y), and so I haven't been able to find an appropriate method to do the same.
the co-ordinates are
{
[10 10]
[11 1]
[12 7]
[14 4]
[16 8]
[17 5]]}
And y=0
for all the unmarked x values
A bit simple and correct?
points = [[10, 10],
[11, 1],
[12, 7],
[14, 4],
[16, 8],
[17, 5]]
areas = []
areas.append( points[0][0]/2.0 )
for i in range(0, points[-1][0] - points[0][0]-2):
if ( points[i+1][0] == points[i][0]+1 ):
areas.append( (points[i+1][1] + points[i][1] )/2.0)
elif ( points[i+1][0] >= points[i][0]+2):
areas.append( (points[i][1] )/2.0)
areas.append( (points[i+1][1] )/2.0)
areas.append( points[-1][1]/2.0 )
print(areas)
>[5.0, 5.5, 4.0, 3.5, 2.0, 2.0, 4.0, 6.5, 2.5]