Message Boards Message Boards


Average of interpolation functions

Posted 5 days ago
4 Replies
3 Total Likes

I have numerous data sets of different length/intervals imported from Excel and am attempting to interpolate each one.

After interpolation, I want to find the average of the data sets so I may plot them along with their standard deviations. My attempts to do this so far has failed, as my interpolation function appears to be giving extremely inaccurate results. Does anyone have an idea as to how I can go about this?

Interpolation is not required, but I do need to figure out how to find the average/standard deviations of my various lists.

I've attached a sample set of data to help explain my issue.

Thank you all!

4 Replies

Hi Eric,

Interpolating is probably not a good idea. Here is one way to compute the mean and standard deviation of stress and strain for the three sheets in the Excel file.

(* Import data from the first 3 sheets *)
data = Import["~/Downloads/Test_Data.xlsx", {"Dataset", 1 ;; 3, All, 5 ;; 6}, 
         HeaderLines -> 1]

(* Compute mean and standard deviation of stress and strain *)
meanStddev = #[All, {"Strain", "Stress"}] & /* Normal /* Values /*
              (Through[{Mean, StandardDeviation}[#]] &) /* Transpose /@ data

{{{0.403469, 0.240323}, {10.729, 5.34928}}, 
{{0.344623, 0.192363}, {10.6931, 5.29}}, 
{{0.325966, 0.199726}, {12.3087, 6.00161}}}

Not sure how you want to present the data. Here is one way. The horizontal axis is the dataset number (sheet) and the vertical axis is the mean with error bars corresponding to +/- standard deviation

Apply[Around, meanStddev, {2}] // Transpose // 
    ListPlot[#1, PlotLabel -> #2, Frame -> True, ImageSize -> 400, 
      PlotRange -> All] &, {#, {"Stress", "Strain"}}] & // 
 Row[#, Spacer[20]] &

enter image description here

Usually for stress and strain they are plotted against each other to estimate Young's modulus (bu fitting a straight line) and yield strength. Mean and standard deviation don'r reveal much.

Posted 5 days ago

Thank you so much Rohit, but I believe I may have mis-worded my question. Each sheet is a singular stress-strain curve of a sample, giving me three curves total. I was attempting to find and plot the mean and standard deviation against the average of the three stress-strain curves for experimental reasons.

Thus, the image would look similar to the one below.

enter image description here

My apologies for the poorly worded question, hopefully this makes things a tad clearer. Any help would be greatly appreciated.

Thank you!


your data have different values for the abscissa. In those cases I find TemporalData quite handy - this I use in combination with Around:

fn = "Test_Data.xlsx";
sheets = Import[fn, "Data"];
tData = TemporalData[rawData = sheets[[All, 2 ;;, {-2, -1}]]];
stress[strain_] := With[{sld = tData["SliceData", strain]}, Around[Mean[sld], StandardDeviation[sld]]]

With this simple function you already can do things like:

enter image description here

and those values can be plotted:

ListLinePlot[Table[{Around[strain, 0.000001], stress[strain]}, {strain, 0, .65, .05}], IntervalMarkers -> "Bands", PlotRange -> {0, 22}, Epilog -> {Point /@ rawData }, ImageSize -> Large]

enter image description here

The statistics is made of just three values here, and so we see the somewhat strange effect that some data points are outside of the "band". Does that help? Regards -- Henrik

Posted 4 days ago

That is exactly what I was looking for. Thank you so much for the help!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract