Created
March 10, 2015 12:13
-
-
Save Piyush3dB/0e377979a4e941021922 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import numpy as np | |
# Specify length of signal | |
N = 512; | |
# Generate time domain signal | |
x = np.random.rand(N).astype('complex') | |
# Evaluate signal power in the time domain | |
pTD = np.inner(np.conj(x),x) | |
# Transform signal to frequency domain | |
X = np.fft.fft(x) | |
# Calculate signal power in the frequency domain | |
pFD = np.inner(np.conj(X),X)/N | |
# pTD must = pFD | |
print "Time Domain Power = " + str(pTD) | |
print "Freq Domain Power = " + str(pFD) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python snippet to show power equivalence between the time domain and frequency domain representation of a discrete signal. An implementation Parseval's Theorem.