Concept Flow - Time shifting a signal
Original Signal x(t)
Choose shift amount T
Apply shift: y(t) = x(t - T)
Shifted Signal y(t)
Start with the original signal, pick how much to shift it in time, then create a new signal shifted by that amount.
import numpy as np import matplotlib.pyplot as plt t = np.linspace(0, 1, 500) x = np.sin(2 * np.pi * 5 * t) T = 0.2 y = np.sin(2 * np.pi * 5 * (t - T))
| Step | t (time) | x(t) = sin(2π5t) | Shift T | y(t) = x(t - T) |
|---|---|---|---|---|
| 1 | 0.000 | 0.000 | 0.2 | sin(2π5*(0-0.2)) = sin(-2π) = 0.000 |
| 2 | 0.250 | sin(2π5*0.25) = sin(2.5π) = -1.000 | 0.2 | sin(2π5*(0.25-0.2)) = sin(2π5*0.05) = sin(0.5π) = 1.000 |
| 3 | 0.400 | sin(2π5*0.4) = sin(4π) = 0.000 | 0.2 | sin(2π5*(0.4-0.2)) = sin(2π5*0.2) = sin(2π) = 0.000 |
| 4 | 0.600 | sin(2π5*0.6) = sin(6π) = 0.000 | 0.2 | sin(2π5*(0.6-0.2)) = sin(2π5*0.4) = sin(4π) = 0.000 |
| 5 | 0.800 | sin(2π5*0.8) = sin(8π) = 0.000 | 0.2 | sin(2π5*(0.8-0.2)) = sin(2π5*0.6) = sin(6π) = 0.000 |
| 6 | 1.000 | sin(2π5*1.0) = sin(10π) = 0.000 | 0.2 | sin(2π5*(1.0-0.2)) = sin(2π5*0.8) = sin(8π) = 0.000 |
| 7 | End | - | - | - |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | After Step 5 | After Step 6 | Final |
|---|---|---|---|---|---|---|---|---|
| t | array from 0 to 1 | 0.000 | 0.250 | 0.400 | 0.600 | 0.800 | 1.000 | 1.000 |
| x(t) | sin(2π5t) | 0.000 | -1.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| T | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 | 0.2 |
| y(t) | sin(2π5(t-T)) | 0.000 | 1.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
Time shifting a signal means moving it left or right on the time axis. Use y(t) = x(t - T) to shift right by T seconds. If T is positive, signal delays; if negative, it advances. Shifting changes when signal features appear but not their shape. Common in signal processing to align or delay signals.
x by 3 units forward (delay)?shifted_x = x.shift(3) is invalid syntax for numpy arrays, np.roll(x, -3) shifts left (advances), x + 3 adds 3 to values (not time shift).x = [1, 2, 3, 4, 5], what is the output of np.roll(x, -2)?x = [10, 20, 30, 40] by 1 unit forward but produces incorrect output. What is the error?shifted_x = np.roll(x, -1)
s1 = [0, 1, 2, 3, 4] and s2 = [3, 4, 0, 1, 2]. Which time shift applied to s1 aligns it best with s2?s1 by -3 units (advance by 3) -> Option DPass the test and this pattern moves unknown