Code Examples
A repository of 155 code examples for BeepBeep
Stdev.java
1 package hl7;
2 
3 import ca.uqac.lif.cep.Connector;
4 import ca.uqac.lif.cep.GroupProcessor;
5 import ca.uqac.lif.cep.functions.ApplyFunction;
6 import ca.uqac.lif.cep.functions.Constant;
7 import ca.uqac.lif.cep.functions.FunctionTree;
8 import ca.uqac.lif.cep.functions.StreamVariable;
9 import ca.uqac.lif.cep.tmf.Fork;
10 import ca.uqac.lif.cep.util.Numbers;
11 
12 public class Stdev extends GroupProcessor
13 {
14  public Stdev()
15  {
16  super(1, 1);
17  Fork f = new Fork(2);
18  StatMoment e2x = new StatMoment(2);
19  Connector.connect(f, 0, e2x, 0);
20  StatMoment ex = new StatMoment(1);
21  Connector.connect(f, 1, ex, 0);
22  ApplyFunction pow2 = new ApplyFunction(new FunctionTree(Numbers.power, StreamVariable.X, new Constant(2)));
23  Connector.connect(ex, pow2);
24  ApplyFunction sub = new ApplyFunction(Numbers.subtraction);
25  Connector.connect(e2x, 0, sub, 0);
26  Connector.connect(pow2, 0, sub, 1);
27  associateInput(0, f, 0);
28  associateOutput(0, sub, 0);
29  addProcessors(f, e2x, ex, pow2, sub);
30  }
31 }