I am doing some works about DSP(digital signal process), and there need to generate a discrete complex white gaussian noise signal. I know I can use numpy.random.normal(0, 1, n) to generate the discrete sequence, but it is in real number field. It is easy to simulate with Matlab, but I wander how to replace matlab code with python?
解决方案
Here's one way you can do it. This generates an array of standard normal variates of shape (n, 2), and then uses the .view() method to view the array as an array of complex values with shape (n,).
In [26]: n = 10
In [27]: z = np.random.randn(n, 2).view(np.complex128)
In [28]: z
Out[28]:
array([[ 0.90179497-0.14081956j],
[-2.17633115+0.88782764j],
[ 0.94807348+0.27575325j],
[-1.25452512+0.64883484j],
[-0.58886548+0.15419947j],
[ 0.58296574&#