Challenge - 5 Problems
Time Scaling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of time-scaled signal array
Given a discrete signal array and a time scaling factor, what is the output array after compression by a factor of 2 using simple downsampling?
Signal Processing
import numpy as np signal = np.array([1, 3, 5, 7, 9, 11, 13, 15]) scaled_signal = signal[::2] print(scaled_signal)
Attempts:
2 left
💡 Hint
Think about how slicing with step works in arrays.
✗ Incorrect
Using signal[::2] picks every second element starting from index 0, resulting in [1, 5, 9, 13].
❓ data_output
intermediateLength of expanded signal after time scaling
If a signal of length 10 is expanded by a factor of 3 using linear interpolation, what will be the length of the new signal?
Attempts:
2 left
💡 Hint
Remember that interpolation adds points between existing samples.
✗ Incorrect
The standard formula for the length after linear interpolation for expansion by factor 3 is (original_length - 1) * 3 + 1 = 9 * 3 + 1 = 28.
🔧 Debug
advancedIdentify the error in time scaling code
What error does the following code produce when trying to compress a signal by a factor of 0.5?
import numpy as np
signal = np.array([2, 4, 6, 8, 10])
compressed_signal = signal[::0.5]
print(compressed_signal)
Signal Processing
import numpy as np signal = np.array([2, 4, 6, 8, 10]) compressed_signal = signal[::0.5] print(compressed_signal)
Attempts:
2 left
💡 Hint
Check the type of the slice step parameter.
✗ Incorrect
Slice step must be an integer or None. Using a float like 0.5 causes a TypeError.
🧠 Conceptual
advancedEffect of time expansion on signal frequency
When a signal is expanded in time by a factor of 2 (stretched), what happens to its frequency components?
Attempts:
2 left
💡 Hint
Think about how stretching time affects the speed of oscillations.
✗ Incorrect
Expanding the signal in time slows down the oscillations, halving the frequencies.
🚀 Application
expertCalculate output signal after time compression with resampling
Given a signal sampled at 1000 Hz with 1000 samples, you compress it by a factor of 0.25 using resampling. What is the new sampling rate and number of samples?
Attempts:
2 left
💡 Hint
Compression by 0.25 means the signal duration is reduced to 25%.
✗ Incorrect
Compressing by 0.25 reduces duration to 25%, so samples reduce to 250. Sampling rate increases to 4000 Hz to maintain the same signal duration.
