Skip to content

Instantly share code, notes, and snippets.

@yuchen-xue
Created May 8, 2025 08:45
Show Gist options
  • Save yuchen-xue/67b7fb72b6ae418d43b10cca2ebda153 to your computer and use it in GitHub Desktop.
Save yuchen-xue/67b7fb72b6ae418d43b10cca2ebda153 to your computer and use it in GitHub Desktop.
Generate a sine wave signal with given amplitude and frequency
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