[ { "name": "simple average of three over 1..5", "args": [[1, 2, 3, 4, 5], 3, "simple", 2], "expect": [2, 3, 4] }, { "name": "exponential over 1..5 with window 3 (alpha 0.5)", "args": [[1, 2, 3, 4, 5], 3, "exponential", 2], "expect": [2, 3, 4] }, { "name": "exponential is seeded with the first window's mean, not the first value", "args": [[2, 4, 6, 8], 3, "exponential", 4], "expect": [4, 6] }, { "name": "exponential with window 4 (alpha 0.4) reacts to a jump", "args": [[1, 2, 3, 4, 10], 4, "exponential", 2], "expect": [2.5, 5.5] }, { "name": "exponential with window 2 (alpha 2/3)", "args": [[10, 20, 30, 40], 2, "exponential", 4], "expect": [15, 25, 35] }, { "name": "exponential with window 1 is the series itself", "args": [[1, 5, 3], 1, "exponential", 2], "expect": [1, 5, 3] }, { "name": "simple with window 1 rounds each value", "args": [[1.26, -0.5], 1, "simple", 1], "expect": [1.3, -0.5] }, { "name": "a window as long as the series gives one value", "args": [[3, 5], 2, "simple", 0], "expect": [4] }, { "name": "a series shorter than the window gives nothing", "args": [[3, 5], 3, "simple", 2], "expect": [] }, { "name": "an empty series gives nothing", "args": [[], 2, "exponential", 2], "expect": [] }, { "name": "a half rounds away from zero", "args": [[0, 1], 2, "simple", 0], "expect": [1] }, { "name": "a negative half rounds away from zero", "args": [[-1, 0], 2, "simple", 0], "expect": [-1] }, { "name": "float drift is rounded away: (0.1 + 0.2) / 2 is 0.15", "args": [[0.1, 0.2], 2, "simple", 6], "expect": [0.15] }, { "name": "5/3 to two places", "args": [[1, 2, 2], 3, "simple", 2], "expect": [1.67] }, { "name": "1.005 is stored just below 1.005, so it rounds to 1.00", "args": [[1.005], 1, "simple", 2], "expect": [1] }, { "name": "a window of 0 is an error", "args": [[1, 2], 0, "simple", 2], "expectError": "window must be a whole number of 1 or greater" }, { "name": "an unknown kind is an error", "args": [[1, 2], 2, "weighted", 2], "expectError": "unknown moving average kind \"weighted\"" }, { "name": "decimals above 12 is an error", "args": [[1, 2], 2, "simple", 13], "expectError": "decimals must be a whole number from 0 to 12" }, { "name": "a non-number value is an error", "args": [[1, null], 1, "simple", 2], "expectError": "values must be finite numbers" } ]