Sign in to follow this  
SteveMyres

Graphing Rolling Averages

Recommended Posts

I want to smooth my graph by using an N-sample rolling average.  In a variable value, I'd just enter

Mean(MyChannel[0,n-1])

which works fine.  Graphs understandably look at channel history differently than variable value components, but I've been unable to find a syntax to generate a rolling average in a graph.  In addition to the above, I also tried subsetting by time (unsure of how the graph would interpret systime(), whether in the instantaneous sense or as seen from a certain location on the axis:

Mean(MyChannel[Systime(), Systime() - n + 1])   // or whatever the desired sample count converts to delta-T

I'm pretty sure it would work to create a second channel, each of whose values is a rolling average of the one I want graphed, but it seems cleaner (though probably less processor-efficient) if there's a way to do it from the original channel on the fly.

Share this post


Link to post
Share on other sites

You want the smooth() function in your graph expression:

 

smooth(myChannel, n)

 

That does a running average where each value is the average of the last n data points.  Use one of the boxcar functions if you'd prefer to reduce the number of data points into boxcars instead of a running average.

 

Mean() always returns a scalar for the given dimension.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this