Many Particle System - Setting up the Initial State¶

Simulation and Modeling (CSCI 3010U)¶

In-class Exercise¶

Due in class. Nothing to submit.

Task¶

Consider the signal $x$ given below. Plot autocorrelation for lags 1 to 10. Use autocorrelation for lag 1 to decide if this signal is random.

In [2]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
x = np.array([-213,  -564,   -35,   -15,   141,   115,  -420,  -360,   
              203,  -338,  -431,   194,  -220,  -513,   154,  -125,  
              -559,    92,   -21,  -579,   -52,    99,  -543,  -175,   
              162,  -457,  -346,   204,  -300,  -474,   164,  -107,  
              -572,    -8,    83,  -541,  -224,   180,  -420,  -374,   
              201,  -236,  -531,    83,    27,  -564,  -112,   131,  
              -507,  -254,   199,  -311,  -495,   143,   -46,  -579,   
              -90,   136,  -472,  -338,   202,  -287,  -477,   169,  
              -124,  -568,    17,    48,  -568,  -135,   162,  -430,  
              -422,   172,   -74,  -577,   -13,    92,  -534,  -243,   
              194,  -355,  -465,   156,   -81,  -578,   -64,   139,  
              -449,  -384,   193,  -198,  -538,   110,   -44,  -577,    
              -6,    66,  -552,  -164,   161,  -460,  -344,   205,  -281,  
              -504,   134,   -28,  -576,  -118,   156,  -437,  -381,   
              200,  -220,  -540,    83,    11,  -568,  -160,   172,  -414,  
              -408,   188,  -125,  -572,   -32,   139,  -492,  -321,   
              205,  -262,  -504,   142,   -83,  -574,     0,    48,  -571,  
              -106,   137,  -501,  -266,   190,  -391,  -406,   194,  
              -186,  -553,    83,   -13,  -577,   -49,   103,  -515,  
              -280,   201,   300,  -506,   131,   -45,  -578,   -80,   
              138,  -462,  -361,   201,  -211,  -554,    32,    74,  -533,  
              -235,   187,  -372,  -442,   182,  -147,  -566,    25,    
              68,  -535,  -244,   194,  -351,  -463,   174,  -125,  -570,    
              15,    72,  -550,  -190,   172,  -424,  -385,   198,  -218,  -536,    96])
In [4]:
plt.figure(figsize=(20,5))
plt.plot(x)
plt.plot(x, '.r')
plt.title('x vs. time')
plt.ylabel('x')
plt.xlabel('time')
Out[4]:
Text(0.5, 0, 'time')
No description has been provided for this image
In [ ]:
 
In [5]:
y = x*2-190
In [6]:
plt.plot(y)
Out[6]:
[<matplotlib.lines.Line2D at 0x115814610>]
No description has been provided for this image
In [7]:
y
Out[7]:
array([ -616, -1318,  -260,  -220,    92,    40, -1030,  -910,   216,
        -866, -1052,   198,  -630, -1216,   118,  -440, -1308,    -6,
        -232, -1348,  -294,     8, -1276,  -540,   134, -1104,  -882,
         218,  -790, -1138,   138,  -404, -1334,  -206,   -24, -1272,
        -638,   170, -1030,  -938,   212,  -662, -1252,   -24,  -136,
       -1318,  -414,    72, -1204,  -698,   208,  -812, -1180,    96,
        -282, -1348,  -370,    82, -1134,  -866,   214,  -764, -1144,
         148,  -438, -1326,  -156,   -94, -1326,  -460,   134, -1050,
       -1034,   154,  -338, -1344,  -216,    -6, -1258,  -676,   198,
        -900, -1120,   122,  -352, -1346,  -318,    88, -1088,  -958,
         196,  -586, -1266,    30,  -278, -1344,  -202,   -58, -1294,
        -518,   132, -1110,  -878,   220,  -752, -1198,    78,  -246,
       -1342,  -426,   122, -1064,  -952,   210,  -630, -1270,   -24,
        -168, -1326,  -510,   154, -1018, -1006,   186,  -440, -1334,
        -254,    88, -1174,  -832,   220,  -714, -1198,    94,  -356,
       -1338,  -190,   -94, -1332,  -402,    84, -1192,  -722,   190,
        -972, -1002,   198,  -562, -1296,   -24,  -216, -1344,  -288,
          16, -1220,  -750,   212,   410, -1202,    72,  -280, -1346,
        -350,    86, -1114,  -912,   212,  -612, -1298,  -126,   -42,
       -1256,  -660,   184,  -934, -1074,   174,  -484, -1322,  -140,
         -54, -1260,  -678,   198,  -892, -1116,   158,  -440, -1330,
        -160,   -46, -1290,  -570,   154, -1038,  -960,   206,  -626,
       -1262,     2])
In [8]:
for i in y:
    print(i)
-616
-1318
-260
-220
92
40
-1030
-910
216
-866
-1052
198
-630
-1216
118
-440
-1308
-6
-232
-1348
-294
8
-1276
-540
134
-1104
-882
218
-790
-1138
138
-404
-1334
-206
-24
-1272
-638
170
-1030
-938
212
-662
-1252
-24
-136
-1318
-414
72
-1204
-698
208
-812
-1180
96
-282
-1348
-370
82
-1134
-866
214
-764
-1144
148
-438
-1326
-156
-94
-1326
-460
134
-1050
-1034
154
-338
-1344
-216
-6
-1258
-676
198
-900
-1120
122
-352
-1346
-318
88
-1088
-958
196
-586
-1266
30
-278
-1344
-202
-58
-1294
-518
132
-1110
-878
220
-752
-1198
78
-246
-1342
-426
122
-1064
-952
210
-630
-1270
-24
-168
-1326
-510
154
-1018
-1006
186
-440
-1334
-254
88
-1174
-832
220
-714
-1198
94
-356
-1338
-190
-94
-1332
-402
84
-1192
-722
190
-972
-1002
198
-562
-1296
-24
-216
-1344
-288
16
-1220
-750
212
410
-1202
72
-280
-1346
-350
86
-1114
-912
212
-612
-1298
-126
-42
-1256
-660
184
-934
-1074
174
-484
-1322
-140
-54
-1260
-678
198
-892
-1116
158
-440
-1330
-160
-46
-1290
-570
154
-1038
-960
206
-626
-1262
2
In [ ]: