Jump to content

Relative (rolling) calculation window


JohnL

Recommended Posts

I've seen some discussions on creating boundaries using periodic conditions. But am interested in seeing if now() can help with creating a relative, rolling window for calculations.

For example, I am trying to create boundaries for temperature signal A (TempA) based on a prediction model for TempA, +/- the standard deviation of the model. Ideally, the StdDev would be calculated continuously over the preceeding 24hrs, offset by 1hr (i.e. the standard deviation of the model between -25h and -1hr).

Right now I've started with this: ($p = prediction model for TempA)

$p.standarddeviation(capsule(now()-25h,now()-1h))

But that yields a constant. And I would like it to continuously calculate over that relative -25hr:-1hr window. 

Link to comment
Share on other sites

Hi John,

The following method can be used to calculate an hourly average and standard deviation over the lagging 24 hours. 

1. Create a periodic condition 24 hours in length that begins every hour. Periodic conditions this specific cannot be done in the Periodic Condition wizard tool, but can be done in Formula using the following syntax: periods(24h, 1h)

image.thumb.png.b8216c2c2f66accab583401b14cddac6.png

2. Use signal from condition to calculate an hourly average over the last 24 hours. Make sure to select end as where you want to put the timestamp of the summary statistic. 

image.png

3. Use a similar method with signal from condition to calculate an hourly standard deviation over the last 24 hours. 

image.thumb.png.13ed0d04af7e7c9a09abdef97e122ef6.png

4. Use formula to calculate an upper limit for your temp signal equal to your 24 hr lagging average + X*standard deviation. In this example we chose + 3 SD, so the formula syntax is $average + (3*$standardDeviation)

image.thumb.png.2b17a4511e419ac6aedf0b3652c85d2b.png

5. Use formula to calculate a lower limit for your temp signal equal to your 24 hr lagging average - X*standard deviation. In this example we chose - 3 SD, so the formula syntax is $average - (3*$standardDeviation)

image.thumb.png.0708dffdc3fe61ad8c14647d114de67e.png

6. Use the Boundaries tool to transform your upper and lower limit signals into shaded boundaries.

image.png

Edited by Allison Buenemann
deleted duplicate screenshots
  • Like 2
Link to comment
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
×
×
  • Create New...