# I How to calculate slope for data set

1. Sep 14, 2016

### joshmccraney

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!

#### Attached Files:

• ###### slope.pdf
File size:
7.4 KB
Views:
47
2. Sep 14, 2016

### andrewkirk

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.

3. Sep 14, 2016

### joshmccraney

Thanks andrewkirk! I'm on it!