|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | | - "id": "settled-retro", |
6 | 5 | "metadata": {}, |
7 | 6 | "source": [ |
8 | 7 | "# `sequgen` demo\n", |
|
13 | 12 | { |
14 | 13 | "cell_type": "code", |
15 | 14 | "execution_count": 1, |
16 | | - "id": "engaging-liabilities", |
17 | 15 | "metadata": {}, |
18 | 16 | "outputs": [], |
19 | 17 | "source": [ |
|
26 | 24 | }, |
27 | 25 | { |
28 | 26 | "cell_type": "markdown", |
29 | | - "id": "stuck-current", |
30 | 27 | "metadata": {}, |
31 | 28 | "source": [ |
| 29 | + "## Time series with static parameters\n", |
| 30 | + "\n", |
32 | 31 | "The time series will consist of two parts: the time points and the data points. For the time points we want to use space between the numbers 0 and 20. We want to divide that space in 100 equal sections so we need 101 points: 100 at the beginning of each section and 1 and the end of the final section. We can define these time points with this command:" |
33 | 32 | ] |
34 | 33 | }, |
35 | 34 | { |
36 | 35 | "cell_type": "code", |
37 | 36 | "execution_count": 2, |
38 | | - "id": "precise-dublin", |
39 | 37 | "metadata": {}, |
40 | 38 | "outputs": [], |
41 | 39 | "source": [ |
|
44 | 42 | }, |
45 | 43 | { |
46 | 44 | "cell_type": "markdown", |
47 | | - "id": "stable-highway", |
48 | 45 | "metadata": {}, |
49 | 46 | "source": [ |
50 | 47 | "We can verify that this process has worked by checking the contents of the variable `time_points`:" |
|
53 | 50 | { |
54 | 51 | "cell_type": "code", |
55 | 52 | "execution_count": 3, |
56 | | - "id": "academic-relief", |
57 | 53 | "metadata": {}, |
58 | 54 | "outputs": [ |
59 | 55 | { |
|
82 | 78 | }, |
83 | 79 | { |
84 | 80 | "cell_type": "markdown", |
85 | | - "id": "adverse-bunny", |
86 | 81 | "metadata": {}, |
87 | 82 | "source": [ |
88 | 83 | "In this time space, we want to create a triangulary shaped signal starting at time point 5 at value 0, rising to value 1 at time point 6 and dropping back to value 0 at time point 10. The following command can achieve this:" |
|
91 | 86 | { |
92 | 87 | "cell_type": "code", |
93 | 88 | "execution_count": 4, |
94 | | - "id": "concrete-collar", |
95 | 89 | "metadata": {}, |
96 | 90 | "outputs": [], |
97 | 91 | "source": [ |
|
100 | 94 | }, |
101 | 95 | { |
102 | 96 | "cell_type": "markdown", |
103 | | - "id": "analyzed-truth", |
104 | 97 | "metadata": {}, |
105 | 98 | "source": [ |
106 | 99 | "So we have asked for a triangular peak with height 1, placed at time position 6, where the left part of the triangle has width 1 (so it starts at 5) and the right part has width 4 (so it ends at time point 10). We can check the contents of the variable `data_points` to verify that the command has worked:" |
|
109 | 102 | { |
110 | 103 | "cell_type": "code", |
111 | 104 | "execution_count": 5, |
112 | | - "id": "pregnant-tracy", |
113 | 105 | "metadata": {}, |
114 | 106 | "outputs": [ |
115 | 107 | { |
|
138 | 130 | }, |
139 | 131 | { |
140 | 132 | "cell_type": "markdown", |
141 | | - "id": "arbitrary-value", |
142 | 133 | "metadata": {}, |
143 | 134 | "source": [ |
144 | 135 | "We notice that the standard value of the data points is zero. Only at the triangle that we have defined the values are non-zero. A graph provides a better view of the shape:" |
|
147 | 138 | { |
148 | 139 | "cell_type": "code", |
149 | 140 | "execution_count": 6, |
150 | | - "id": "acknowledged-world", |
151 | 141 | "metadata": {}, |
152 | 142 | "outputs": [ |
153 | 143 | { |
|
176 | 166 | }, |
177 | 167 | { |
178 | 168 | "cell_type": "markdown", |
179 | | - "id": "endless-thinking", |
180 | 169 | "metadata": {}, |
181 | 170 | "source": [ |
| 171 | + "## Time series with random parameters\n", |
| 172 | + "\n", |
182 | 173 | "Often, we want to to allow for some variance in the signal. For example, we could have the height of the peak vary between 1 and 2, the peak position could vary between 3 and 10, the left width of the triangle could vary between 0.5 and 1, and the right width of the triangle could vary between 4 and 6. We can define these variations in a parameter space:" |
183 | 174 | ] |
184 | 175 | }, |
185 | 176 | { |
186 | 177 | "cell_type": "code", |
187 | 178 | "execution_count": 7, |
188 | | - "id": "minute-minister", |
189 | 179 | "metadata": {}, |
190 | 180 | "outputs": [], |
191 | 181 | "source": [ |
|
199 | 189 | }, |
200 | 190 | { |
201 | 191 | "cell_type": "markdown", |
202 | | - "id": "infinite-yield", |
203 | 192 | "metadata": {}, |
204 | 193 | "source": [ |
205 | 194 | "Next, we generate a set of arbitrary values based on this parameter space:" |
|
208 | 197 | { |
209 | 198 | "cell_type": "code", |
210 | 199 | "execution_count": 8, |
211 | | - "id": "fluid-narrow", |
212 | 200 | "metadata": {}, |
213 | 201 | "outputs": [], |
214 | 202 | "source": [ |
|
217 | 205 | }, |
218 | 206 | { |
219 | 207 | "cell_type": "markdown", |
220 | | - "id": "compact-device", |
221 | 208 | "metadata": {}, |
222 | 209 | "source": [ |
223 | 210 | "We can verify that the parameter value generation was successful by checking the value of the `parameters` variable:" |
|
226 | 213 | { |
227 | 214 | "cell_type": "code", |
228 | 215 | "execution_count": 9, |
229 | | - "id": "cordless-lover", |
230 | 216 | "metadata": {}, |
231 | 217 | "outputs": [ |
232 | 218 | { |
|
249 | 235 | }, |
250 | 236 | { |
251 | 237 | "cell_type": "markdown", |
252 | | - "id": "wireless-mentor", |
253 | 238 | "metadata": {}, |
254 | 239 | "source": [ |
255 | 240 | "Each time you run the `sample` command, you will get a different set of values. The parameters can be used to create new data points:" |
|
258 | 243 | { |
259 | 244 | "cell_type": "code", |
260 | 245 | "execution_count": 10, |
261 | | - "id": "historic-waste", |
262 | 246 | "metadata": {}, |
263 | 247 | "outputs": [], |
264 | 248 | "source": [ |
|
267 | 251 | }, |
268 | 252 | { |
269 | 253 | "cell_type": "markdown", |
270 | | - "id": "negative-treasury", |
271 | 254 | "metadata": {}, |
272 | 255 | "source": [ |
273 | 256 | "And the graph that corresponds with these data points can then be plotted. This time we mention the parameter values in the title of the graph:" |
|
276 | 259 | { |
277 | 260 | "cell_type": "code", |
278 | 261 | "execution_count": 11, |
279 | | - "id": "constant-patch", |
280 | 262 | "metadata": {}, |
281 | 263 | "outputs": [ |
282 | 264 | { |
|
299 | 281 | }, |
300 | 282 | { |
301 | 283 | "cell_type": "markdown", |
302 | | - "id": "victorian-connection", |
303 | 284 | "metadata": {}, |
304 | 285 | "source": [ |
305 | 286 | "Notice that this graph might have a slightly different shape than the previous one. This depends on the position of the peak. Only when the position of the peak (parameter `placement`) coincides with a time point, will the signal shape be perfectly triangular. But since the peak position now is an arbitrary value, this is usually not the case. And when the peak position does not match a time point, the triangle can be slightly irregular at the top." |
|
0 commit comments