diff --git a/src/Bonsai.ML.LinearDynamicalSystems/StateComponent.cs b/src/Bonsai.ML.LinearDynamicalSystems/StateComponent.cs
index 77f70da8..e3e56f2d 100644
--- a/src/Bonsai.ML.LinearDynamicalSystems/StateComponent.cs
+++ b/src/Bonsai.ML.LinearDynamicalSystems/StateComponent.cs
@@ -1,5 +1,6 @@
using System.ComponentModel;
using System;
+using System.Reactive.Linq;
using System.Xml.Serialization;
using Newtonsoft.Json;
@@ -8,7 +9,9 @@ namespace Bonsai.ML.LinearDynamicalSystems
///
/// State component of a Kalman Filter
///
- [Description("State component of a Kalman Filter")]
+ [Description("State component of a Kalman Filter")]
+ [Combinator()]
+ [WorkflowElementCategory(ElementCategory.Source)]
public class StateComponent
{
@@ -61,9 +64,45 @@ public StateComponent(double[,] X, double[,] P, int i)
Variance = Sigma(P[i,i]);
}
+ ///
+ /// Creates a new state compenent
+ ///
+ public StateComponent(double mean, double variance)
+ {
+ Mean = mean;
+ Variance = variance;
+ }
+
private double Sigma(double variance)
{
return 2 * Math.Sqrt(variance);
}
+
+ ///
+ /// Given an observable sequence, this function returns an observable sequence of state components for each element in the input sequence
+ /// ///
+ public IObservable Process(IObservable source)
+ {
+ return Observable.Select(source, value =>
+ {
+ return new StateComponent (
+ Mean = Mean,
+ Variance = Variance
+ );
+ });
+ }
+
+ ///
+ /// This function returns an observable sequence of state components
+ /// ///
+ public IObservable Process()
+ {
+ return Observable.Return(
+ new StateComponent (
+ Mean = Mean,
+ Variance = Variance
+ )
+ );
+ }
}
}