David Kierans
David Kierans

Reputation: 1599

How to calculate numerical trend lines in python

I have a monitoring application in python 2.6 that calculates the number of entries in a queue (queue_len). I want to create a simple function that can use these queue_len rate of change values over time and extract a trend from them.

The goal is to start up or shut down queue processing nodes depending of the +ive or -ive trend over time and not flip flop.

MACD from the financial arena looks sort of what I need or does it? Looking for any help here.

Upvotes: 1

Views: 2789

Answers (1)

Blender
Blender

Reputation: 298176

Isn't that just a simple derivative?

def derivs(l):
  return [l[i + 1] - l[i] for i in range(len(l) - 1)]

Upvotes: 1

Related Questions