Area under curve when missing values
epiphenom
I have waves that look like the picture attached where sometimes there are one or several values missing. In the example graph there is a value missing close to the end of the x axis.
My question is how can I take the area under the curve in this case? Would I have to fit the data through spline interpolation for ex. and then assign a value where it is missing?
I would appreciate if people could comment on the mathematical process to determine the area under the curve given missing values and any help as to how this may be implement in Igor would be further appreciated.
Thanks for your time
If area(…) or integrate … cannot handle NaN values, then convert them to zero.
You could write a trapezoidal rule or integration function and handle NaN.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
November 21, 2013 at 12:17 pm - Permalink
Thanks
November 21, 2013 at 07:26 pm - Permalink
If you're uncertain how to treat the NANs maybe you should look at the effect of these methods by replacing values in a good data set with NANs and proceding with the modifications.
November 22, 2013 at 06:37 am - Permalink
In addition, I would ask how accurately do you need to calculate the area? Your trace has peaks that are for all intents only 1 data point. Rectangular, trapezoidal, and triangular integration will give three different answers for such peaks. Which one do you want?
My suggestion … Since your spectrum seems to have only a few NaN values and those values appear to be on the baseline of your overall spectrum, set them to zero. Alternatively, set them to the half-way point of the two values to either side. Here are the one-line methods ...
mywave = numtype(mywave[p]) == 2 ? (mywave[p - 1] + mywave[p + 1])/2 : mywave[p] // set to half value of neighbors
I leave the exercise in the second case for you to handle the cases where the NaN values are at the end points of the wave and/or fall sequentially one right after the other.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAHuntsville
November 22, 2013 at 08:31 am - Permalink
November 25, 2013 at 01:59 am - Permalink