How to calculate slope for data set

  • Context: Undergrad 
  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Data Set Slope
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
member 428835
Hi PF!

I have some data (y-value data and x-value data) which I can plot to make a curve (see attachment, the top curve). However, when trying to compute the slope of this data I have an issue (see attachment, the bottom "curve"). The formula I am using for slope is ##(y_{i+1}-y_{i-1})/(2 \Delta x)##.

To me it seems the issue is I have way too much data. Many of the y data values for some small neighborhood in the domain are the same due to measurement errors (measuring can only be so accurate). Should I simply omit all but, say, every 10th data value? Is this scientifically acceptable (results will be published)?

I can explain more if you need. Thanks!
 

Attachments

Physics news on Phys.org
It sounds like what you want to do is to fit a curve to the data. A couple of different things you could do are

1. Find a function with a few parameters that has the broad shape of the curve you drew, then use optimization techniques to estimate those parameters by something like minimizing sums of squares of errors. this is a non-linear equivalent of linear regression.

2. Aggregate data along the horizontal axis into bins and then just plot the average value for all observations in each bin.
 
  • Like
Likes   Reactions: member 428835