Lesson 4 of 15
Signal Power and Energy
Signal Power and Energy
Two fundamental quantities describe the "strength" of a signal.
Signal Energy
The energy of a discrete signal over samples is the sum of squared values:
Signal Power
The average power is energy normalized by the number of samples:
RMS (Root Mean Square)
The RMS value is the square root of average power — it represents the effective amplitude:
For a pure sinusoid , the RMS is .
Example
For the signal (alternating ):
- Energy
- Power
- RMS
For :
- Power
- RMS
Your Task
Implement:
signal_power(samples)— returnssignal_energy(samples)— returnsrms(samples)— returns
import math
def signal_power(samples):
return sum(x**2 for x in samples) / len(samples)
def signal_energy(samples):
return sum(x**2 for x in samples)
def rms(samples):
return math.sqrt(signal_power(samples))Python runtime loading...
Loading...
Click "Run" to execute your code.