Search code examples
c#mongodbintegral

How to calculate the integral of time and speed having db in mongodb and c#


I have a database of a car which is done using MongoDB. The backend of my application is done using C#. In my database, I have data about current speed and current time (timestamp). I need to calculate what is the distance covered since the given date. The solution would to calculate the integral of speed, but how?


Solution

  • For most accurate answer you need to calculate linear regression representation of the given points which it will give you y= mx +b function Then you can calculate the integral of any range which will be the distance that you are looking for . Assuming the speed is changing , if not just the average of the speed will do the trick .