MovingAverage
Inputs: i1
Outputs: o1
Computes the moving average (MA) within the time window specified by the provided integer (n).
The MovingAverage
operator holds a message buffer on i1
with a size defined by the length of the provided integer (n). Once the message buffer on i1
gets filled it calculates the MA and emits a message through o1
right after the message buffer on i1
gets filled. The value field of the emitted message is the calculated MA and the time field is the time of the newest message on the buffer.
Parameters
id: The id of the operator
n: The window size, in grid steps, to be used in the computation.
Usage
- TypeScript
- Python
- C++
- YAML
- Json
import { Program, MovingAverage } from "@rtbot-dev/rtbot";
const id = "id";
const n = 20;
const program = new Program();
program.addOperator(new MovingAverage(id, n));
import rtbot as rb
id = "id";
n = 20;
program = rb.Program()
program.addOperator(rb.MovingAverage(id, n))
#include "rtbot/MovingAverage.h"
auto id = "id";
auto n = 20;
auto op = MovingAverage<std::uint64_t, double>(id, n)
# minimal RtBot program
operators:
- type: MovingAverage
id: "id"
n: 20
{
"operators": [
{ "type": "MovingAverage", "id": "id", "n": 20 }
]
}