Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import scipy as sp
- import matplotlib.pyplot as plt
- N = 1024
- num_samples = 100000
- X = np.random.normal(size=(num_samples, 1024))
- X_hat = np.fft.fft(X, axis=-1)
- fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(10, 8))
- fig.suptitle('Distribution of DFT of real-valued Gaussian white noise\n$N=1024$, # Samples = 100,000')
- ax[0,0].grid()
- ax[0,0].hist(np.real(X_hat[:, 0]), bins=100, density=True, label='Observed')
- dom = np.linspace(-140, 140, 100)
- ax[0,0].plot(dom, sp.stats.norm.pdf(dom, scale=np.sqrt(N)), label='Theoretical')
- ax[0,0].legend()
- ax[0,0].set_title('Distribution of $\\hat{X}_0^\\mathrm{real}$')
- ax[0,1].grid()
- ax[0,1].hist(np.imag(X_hat[:, 0]), bins=100, density=True, label='Observed')
- dom = np.linspace(-140, 140, 100)
- ax[0,1].set_title('Distribution of $\\hat{X}_0^\\mathrm{imag}$')
- ax[1,0].grid()
- ax[1,0].hist(np.real(X_hat[:, 3]), bins=100, density=True, label='Observed')
- dom = np.linspace(-140, 140, 100)
- ax[1,0].plot(dom, sp.stats.norm.pdf(dom, scale=np.sqrt(N/2)), label='Theoretical')
- ax[1,0].set_title('Distribution of $\\hat{X}_3^\\mathrm{real}$')
- ax[1,1].grid()
- ax[1,1].hist(np.imag(X_hat[:, 3]), bins=100, density=True, label='Observed')
- dom = np.linspace(-140, 140, 100)
- ax[1,1].plot(dom, sp.stats.norm.pdf(dom, scale=np.sqrt(N/2)), label='Theoretical')
- ax[1,1].set_title('Distribution of $\\hat{X}_3^\\mathrm{imag}$')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement