1

I how do i calculate trendline/slop in c# for a time series data this is the general formula slope = (y1-y2)/(x1-x2) my data looks like this

DateTime            Value 
10/5/2016 14:50     45 
10/5/2016 15:10     50 
10/5/2016 15:20     53 
10/5/2016 15:30     60

I looked at this like for reference but I am not able understand how time will be computed? How do I calculate a trendline for a graph?

Community
  • 1
  • 1
kumar
  • 8,207
  • 20
  • 85
  • 176
  • 2
    You could represent your `DateTime` as `long` using `Ticks` property and use your formula without problems – Paweł Hemperek Oct 05 '16 at 12:06
  • What Pawel said, and then be aware that the slope is in units of `ValueUnit/Tick` which will probably be quite a small number. Excel for example gives the slope in `ValueUnit/Day` (if I remember correctly), so don't be suprised to see magnitudes in difference (as given by `TimeSpan.TicksPerSecond`) – Jens Oct 05 '16 at 12:11
  • This question is far too broad for StackOverflow. No-one here is willing to give you the whole code for this, you have to provide some own affords. Stack is for specific problems, that´s when you´re stuck with the compiler for example or when your expected resulst don´t fit what you got instead. – MakePeaceGreatAgain Oct 05 '16 at 12:15
  • This question was asked here. https://stackoverflow.com/questions/43224/how-do-i-calculate-a-trendline-for-a-graph – irperez Nov 17 '17 at 03:03

0 Answers0