Data Plotting Help: Calculating Error Bars for Gradients and Average Gradient

  • Context: Undergrad 
  • Thread starter Thread starter K41
  • Start date Start date
  • Tags Tags
    Data Plotting
Click For Summary
SUMMARY

This discussion focuses on calculating error bars for gradients derived from experimental data in MATLAB. The user employs the polyfit and polyval functions to determine the line of best fit for the volume of water over time. To compute error bars for individual gradients, the standard deviation of the volumes is suggested, leading to the standard error. For the average gradient, a weighted average using the inverse squares of the uncertainties is recommended, ensuring accurate representation of the data.

PREREQUISITES
  • Understanding of MATLAB programming, specifically polyfit and polyval functions.
  • Knowledge of statistical concepts such as standard deviation and standard error.
  • Familiarity with the concept of weighted averages and their application in data analysis.
  • Basic understanding of linear regression and how to interpret gradients.
NEXT STEPS
  • Research MATLAB error bar plotting techniques to visualize uncertainties in data.
  • Learn about weighted averages in statistics to improve data analysis accuracy.
  • Explore standard error calculations for better understanding of data variability.
  • Investigate linear regression analysis to enhance skills in fitting models to experimental data.
USEFUL FOR

Researchers, data analysts, and scientists conducting experiments that involve time-series data and require accurate representation of gradients and uncertainties in their findings.

K41
Messages
94
Reaction score
1
I'm doing an experiment at work where I am observing an "event" over time. This event can be anything, but let's assume its a bucket of water being filled to the top, then it gets replaced with another bucket and I watch the whole "event" again.

So x-axis will be time, y-axis will be the volume of water in the bucket at time, x. For the first observation, I put a line of best fit which models how the volume of water increases with time. I get the gradient from this. I then plot the next event. I get another gradient. I then plot the third event. I get a third gradient and so fourth.

1) Now here comes an issue. I want to plot the gradient against the event number. This is easily doable. But how would I work out what the error bars would be for each gradient?

Potential Ans. I'm thinking maybe I have to find the standard deviation of the volumes and then get a standard error from this and use that for my error bars?

2) Also, I have plotted an average gradient (its the mean of all the gradients). I want to find the error bar for this. How do I do that?

Potential Ans: I'm thinking just find the standard deviation of the gradients, then compute the standard error. But I'm not sure how the error bars from each individual gradient should be taken into account.

Any advice?
 
Physics news on Phys.org
djpailo said:
But how would I work out what the error bars would be for each gradient?
How do you get the central value? Every good approach (=a fit) should give both at the same time.
djpailo said:
2) Also, I have plotted an average gradient (its the mean of all the gradients). I want to find the error bar for this. How do I do that?
Make a weighted average of the gradients, where the weights are the inverse squares of the uncertainties. If the uncertainties are all very similar, an unweighted average can do the job as well.
 
mfb said:
How do you get the central value? Every good approach (=a fit) should give both at the same time.
Make a weighted average of the gradients, where the weights are the inverse squares of the uncertainties. If the uncertainties are all very similar, an unweighted average can do the job as well.

My measurements of the volume are taken with a code (processing experimental data) in Matlab. I use the polyfit and polyval function to put a line of best fit and this gives me its intercept and gradient. (Polyfit gives the line of best fit and polyval enables me to plot the line of best fit over the data points).

I understand the second answer, thanks.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
28
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
2
Views
3K
  • · Replies 37 ·
2
Replies
37
Views
5K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 2 ·
Replies
2
Views
5K