Step 1: Understand autocorrelation output length and midpoint
Input length is 8, so correlation length is 15, midpoint at index 7.
Step 2: Find max correlation lag after midpoint
Correlation peaks at lag 4 (pattern repeats every 4 samples), so np.argmax(correlation[8:]) + 1 = 4.
Final Answer:
4 -> Option D
Quick Check:
Pitch period = 4 samples [OK]
Hint: Pitch period = lag with highest autocorrelation after zero lag [OK]
Common Mistakes:
Choosing zero lag as pitch period
Off-by-one error in indexing
Misunderstanding correlation midpoint
4. The following code attempts to find the pitch period but gives incorrect results. What is the main error?
import numpy as np
x = np.array([0, 1, 0, -1, 0, 1, 0, -1])
correlation = np.correlate(x, x, mode='full')
pitch_period = np.argmax(correlation) # Incorrect line
print(pitch_period)
medium
A. It should use np.min instead of np.argmax
B. It uses the wrong input array for correlation
C. It finds the max correlation over full range including negative lags
D. It misses normalizing the correlation
Solution
Step 1: Analyze np.argmax usage on full correlation
Using np.argmax on full correlation finds max at zero lag (center), not pitch period lag.
Step 2: Correct approach is to find max after midpoint
Pitch period is lag > 0 with max correlation, so search only after midpoint.
Final Answer:
It finds the max correlation over full range including negative lags -> Option C
Quick Check:
Max correlation at zero lag is not pitch period [OK]
Hint: Search max correlation only after zero lag index [OK]
Common Mistakes:
Taking max correlation at zero lag as pitch
Ignoring lag indexing after midpoint
Confusing normalization with lag selection
5. You have a recorded audio signal sampled at 8000 Hz. Using autocorrelation, you find the pitch period is 160 samples. What is the pitch frequency in Hz? How would you calculate it?
hard
A. 50 Hz, calculated as sample_rate / pitch_period
B. 160 Hz, calculated as pitch_period / sample_rate
C. 8000 Hz, the sample rate itself
D. 0.02 Hz, calculated as pitch_period * sample_rate
Solution
Step 1: Understand pitch frequency formula
Pitch frequency = sample rate divided by pitch period (in samples).
Step 2: Calculate pitch frequency
Pitch frequency = 8000 / 160 = 50 Hz.
Final Answer:
50 Hz, calculated as sample_rate / pitch_period -> Option A
Quick Check:
Frequency = 8000 / 160 = 50 Hz [OK]
Hint: Pitch frequency = sample rate ÷ pitch period [OK]
Common Mistakes:
Dividing pitch period by sample rate instead
Using sample rate as frequency directly
Multiplying pitch period by sample rate
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.