Skip to content

Instantly share code, notes, and snippets.

@mikedewar mikedewar/ar2.json

Created Nov 10, 2015
Embed
What would you like to do?
AR(2) model in streamtools
{"blocks":[{"label":"a","type":"*","id":1,"inputs":[{"name":"x","value":null,"type":"number"},{"name":"y","value":{"data":0.99},"type":"number"}],"outputs":[{"name":"x*y","type":"number"}],"source":null,"position":{"x":1103,"y":564}},{"label":"yt","type":"identity","id":4,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":926,"y":661}},{"label":"","type":"delay","id":6,"inputs":[{"name":"in","value":null,"type":"any"},{"name":"duration","value":{"data":"1s"},"type":"string"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":941,"y":871}},{"label":"","type":"latch","id":9,"inputs":[{"name":"in","value":null,"type":"any"},{"name":"ctrl","value":null,"type":"boolean"}],"outputs":[{"name":"true","type":"any"},{"name":"false","type":"any"}],"source":null,"position":{"x":572,"y":690}},{"label":"","type":"first","id":10,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"first","type":"any"}],"source":null,"position":{"x":468,"y":767}},{"label":"y0","type":"identity","id":12,"inputs":[{"name":"in","value":{"data":10},"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":420,"y":680}},{"label":"","type":"log","id":15,"inputs":[{"name":"log","value":null,"type":"any"}],"outputs":[],"source":null,"position":{"x":1017,"y":751}},{"label":"b","type":"*","id":36,"inputs":[{"name":"x","value":null,"type":"number"},{"name":"y","value":{"data":-0.3},"type":"number"}],"outputs":[{"name":"x*y","type":"number"}],"source":null,"position":{"x":1139,"y":681}},{"label":"","type":"+","id":37,"inputs":[{"name":"x","value":null,"type":"number"},{"name":"y","value":null,"type":"number"}],"outputs":[{"name":"x+y","type":"number"}],"source":null,"position":{"x":1267,"y":591}},{"label":"yt-1","type":"identity","id":43,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":1070,"y":803}},{"label":"","type":"delay","id":45,"inputs":[{"name":"in","value":null,"type":"any"},{"name":"duration","value":{"data":"1s"},"type":"string"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":1159,"y":862}},{"label":"yt-2","type":"identity","id":47,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":1264,"y":805}},{"label":"you","type":"identity","id":54,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":817,"y":434}},{"label":"messy","type":"identity","id":55,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":1009,"y":446}},{"label":"motherfucker","type":"identity","id":56,"inputs":[{"name":"in","value":null,"type":"any"}],"outputs":[{"name":"out","type":"any"}],"source":null,"position":{"x":1170,"y":457}}],"sources":[],"links":[],"connections":[{"from":{"id":10,"route":0},"to":{"id":9,"route":1},"id":11},{"from":{"id":4,"route":0},"to":{"id":15,"route":0},"id":16},{"from":{"id":12,"route":0},"to":{"id":10,"route":0},"id":17},{"from":{"id":1,"route":0},"to":{"id":37,"route":0},"id":38},{"from":{"id":36,"route":0},"to":{"id":37,"route":1},"id":40},{"from":{"id":6,"route":0},"to":{"id":43,"route":0},"id":44},{"from":{"id":43,"route":0},"to":{"id":45,"route":0},"id":46},{"from":{"id":45,"route":0},"to":{"id":47,"route":0},"id":48},{"from":{"id":37,"route":0},"to":{"id":4,"route":0},"id":49},{"from":{"id":43,"route":0},"to":{"id":1,"route":0},"id":50},{"from":{"id":47,"route":0},"to":{"id":36,"route":0},"id":51},{"from":{"id":4,"route":0},"to":{"id":6,"route":0},"id":52},{"from":{"id":9,"route":0},"to":{"id":6,"route":0},"id":53},{"from":{"id":12,"route":0},"to":{"id":9,"route":0},"id":57}],"groups":[]}
@mikedewar

This comment has been minimized.

Copy link
Owner Author

mikedewar commented Nov 10, 2015

image

@mikedewar

This comment has been minimized.

Copy link
Owner Author

mikedewar commented Nov 10, 2015

Every second the log will create the next value of the AR(2) process. The pattern operates through 2 delays - one creates a sample delayed by one second and the other creates a sample delayed by 2 seconds. These are then weighted and summed, before triggering a draw from the normal distribution. Each output is fed back into the delays.

Note that both delays should be initialised ( TODO: in fact it's slightly unclear what is being simulated if only the first is initialised).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.