0
0
SciPydata~10 mins

Peak finding (find_peaks) in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the peak finding function from scipy.

SciPy
from scipy.signal import [1]
Drag options to blanks, or click blank then click option'
Apeak_find
Bfind_peaks
Cfind_peak
Dpeaks_find
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular 'find_peak' instead of 'find_peaks'.
Mixing up the order of words in the function name.
2fill in blank
medium

Complete the code to find peaks in the data array.

SciPy
peaks, _ = find_peaks([1])
Drag options to blanks, or click blank then click option'
Adata
Bsignal
Carray
Dpeaks
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the wrong variable name to find_peaks.
Using the output variable as input.
3fill in blank
hard

Fix the error in the code to find peaks with a minimum height of 5.

SciPy
peaks, _ = find_peaks(data, height=[1])
Drag options to blanks, or click blank then click option'
A{'min': 5}
Bmin=5
Cheight=5
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a dictionary instead of a number to height.
Using keyword-like strings such as 'min=5' or 'height=5'.
4fill in blank
hard

Fill both blanks to create a dictionary of peak heights and filter peaks taller than 3.

SciPy
peak_heights = {peak: [1] for peak in peaks if [2] > 3}
Drag options to blanks, or click blank then click option'
Adata[peak]
Bpeak
Attempts:
3 left
💡 Hint
Common Mistakes
Using the peak index instead of the data value for height.
Comparing the peak index to 3 instead of the height.
5fill in blank
hard

Fill all three blanks to create a dictionary of peaks with heights above 4 and return their indices.

SciPy
result = [1](peak: [2] for peak in peaks if [3] > 4)
Drag options to blanks, or click blank then click option'
Adict
Bdata[peak]
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using list instead of dict.
Using peak index instead of height for filtering.