Created
May 8, 2025 08:45
-
-
Save yuchen-xue/67b7fb72b6ae418d43b10cca2ebda153 to your computer and use it in GitHub Desktop.
Generate a sine wave signal with given amplitude and frequency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.typing as npt | |
def generate_sine_wave(time_steps: npt.NDArray, amp: float, freq: float) -> npt.NDArray: | |
"""Generate a sine wave signal with given amplitude and frequency. | |
Args: | |
time_steps (npt.NDArray): _Time steps in the form of an 1D array_ | |
amp (float): _Amplitude of the sine wave_ | |
freq (float): _Frequency of the sine wave_ | |
Returns: | |
npt.NDArray: _returns the sine wave in the form of an 1D array_ | |
""" | |
return amp * np.sin(2 * np.pi * freq * time_steps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment