Follow ______ on twitter.

7.5.2 Noise reduction techniques in time series modeling

Code

Vega-Lite Chart

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "Noise Reduction Techniques: Kalman Filter Examples",
  "hconcat": [
    {
      "title": "Kalman Filter: Uptrending Data",
      "width": 300,
      "height": 200,
      "data": {
        "values": [
          {
            "time": 0,
            "true_state": 0,
            "measurement": 0.1,
            "kalman_estimate": 0.05
          },
          {
            "time": 1,
            "true_state": 1,
            "measurement": 1.2,
            "kalman_estimate": 1.1
          },
          {
            "time": 2,
            "true_state": 2,
            "measurement": 2.3,
            "kalman_estimate": 2.15
          },
          {
            "time": 3,
            "true_state": 3,
            "measurement": 2.7,
            "kalman_estimate": 2.85
          },
          {
            "time": 4,
            "true_state": 4,
            "measurement": 4.5,
            "kalman_estimate": 4.25
          },
          {
            "time": 5,
            "true_state": 5,
            "measurement": 4.8,
            "kalman_estimate": 4.9
          },
          {
            "time": 6,
            "true_state": 6,
            "measurement": 6.3,
            "kalman_estimate": 6.15
          },
          {
            "time": 7,
            "true_state": 7,
            "measurement": 6.9,
            "kalman_estimate": 6.95
          },
          {
            "time": 8,
            "true_state": 8,
            "measurement": 8.2,
            "kalman_estimate": 8.1
          },
          {
            "time": 9,
            "true_state": 9,
            "measurement": 9.1,
            "kalman_estimate": 9.05
          }
        ]
      },
      "transform": [
        {
          "fold": [
            "true_state",
            "measurement",
            "kalman_estimate"
          ],
          "as": [
            "type",
            "value"
          ]
        }
      ],
      "mark": "line",
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time"
        },
        "y": {
          "field": "value",
          "type": "quantitative",
          "title": "Value"
        },
        "color": {
          "field": "type",
          "type": "nominal",
          "scale": {
            "domain": [
              "true_state",
              "measurement",
              "kalman_estimate"
            ],
            "range": [
              "green",
              "red",
              "blue"
            ]
          },
          "title": "Data Type"
        }
      }
    },
    {
      "title": "Kalman Filter: Seasonal Data",
      "width": 300,
      "height": 200,
      "data": {
        "values": [
          {
            "time": 0,
            "true_state": 0,
            "measurement": 0.2,
            "kalman_estimate": 0.1
          },
          {
            "time": 1,
            "true_state": 0.5,
            "measurement": 0.7,
            "kalman_estimate": 0.6
          },
          {
            "time": 2,
            "true_state": 0.8,
            "measurement": 1,
            "kalman_estimate": 0.9
          },
          {
            "time": 3,
            "true_state": 1,
            "measurement": 0.8,
            "kalman_estimate": 0.9
          },
          {
            "time": 4,
            "true_state": 0.8,
            "measurement": 1.1,
            "kalman_estimate": 0.95
          },
          {
            "time": 5,
            "true_state": 0.5,
            "measurement": 0.3,
            "kalman_estimate": 0.4
          },
          {
            "time": 6,
            "true_state": 0,
            "measurement": -0.2,
            "kalman_estimate": -0.1
          },
          {
            "time": 7,
            "true_state": -0.5,
            "measurement": -0.7,
            "kalman_estimate": -0.6
          },
          {
            "time": 8,
            "true_state": -0.8,
            "measurement": -1,
            "kalman_estimate": -0.9
          },
          {
            "time": 9,
            "true_state": -1,
            "measurement": -0.8,
            "kalman_estimate": -0.9
          },
          {
            "time": 10,
            "true_state": -0.8,
            "measurement": -1.1,
            "kalman_estimate": -0.95
          },
          {
            "time": 11,
            "true_state": -0.5,
            "measurement": -0.3,
            "kalman_estimate": -0.4
          }
        ]
      },
      "transform": [
        {
          "fold": [
            "true_state",
            "measurement",
            "kalman_estimate"
          ],
          "as": [
            "type",
            "value"
          ]
        }
      ],
      "mark": "line",
      "encoding": {
        "x": {
          "field": "time",
          "type": "quantitative",
          "title": "Time"
        },
        "y": {
          "field": "value",
          "type": "quantitative",
          "title": "Value"
        },
        "color": {
          "field": "type",
          "type": "nominal",
          "scale": {
            "domain": [
              "true_state",
              "measurement",
              "kalman_estimate"
            ],
            "range": [
              "green",
              "red",
              "blue"
            ]
          },
          "title": "Data Type"
        }
      }
    }
  ]
}