【问题标题】:How can I implement bivariate normal Gaussian noise?如何实现双变量正态高斯噪声?
【发布时间】:2015-03-31 05:20:59
【问题描述】:

我想在python或C中实现复杂的标准高斯噪声。这个图显示了我想要实现的。

首先我在 python 中实现它,像这样。

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pylab as pl

size = 100000
BIN = 70

x = np.random.normal(0.0,1.0,size)
y = np.random.normal(0.0,1.0,size)

xhist = pl.hist(x,bins = BIN,range=(-3.5,3.5),normed = True)
yhist = pl.hist(y,bins = BIN,range=(-3.5,3.5),normed = True)
xmesh = np.arange(-3.5,3.5,0.1)
ymesh = np.arange(-3.5,3.5,0.1)
Z = np.zeros((BIN,BIN))
    for i in range(BIN):
     for j in range(BIN):
         Z[i][j] = xhist[0][i] + yhist[0][j]
X,Y = np.meshgrid(xmesh,ymesh)
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_wireframe(X,Y,Z)
plt.show()

但是,它不是标准的复高斯噪声。

输出图变成:

我认为高斯噪声是相加的,但是,为什么它变得如此不同?

我已经尝试过修改部分代码

x = np.random.normal(0.0,1.0,size)
y = np.random.normal(0.0,1.0,size)

r = np.random.normal(0.0,1.0,size)
theta = np.random.uniform(0.0,2*np.pi,size)
x = r * np.cos(theta)
y = r * np.sin(theta)

但是,结果是一样的。

请告诉我双变量标准高斯噪声的正确实现或方程。

【问题讨论】:

    标签: python random gaussian noise


    【解决方案1】:

    对不起,是我的错。

    联合概率由乘积定义,而不是总和。我是个十足的傻瓜!

    所以

    Z[i][j] = xhist[0][i] + yhist[0][j]
    

    术语必须变成

    Z[i][j] = xhist[0][i] * yhist[0][j]
    

    我检查了

    for i in range(BIN):
        for j in range(BIN):
            integral = integral + Z[i][j] * 0.01
    

    将是 1.0。

    所以如果我们需要复杂的标准高斯噪声,我们应该将实部标准高斯噪声添加到实部和虚部。

    这是用于比较的图表。

    【讨论】:

      猜你喜欢
      • 2016-02-07
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 2016-08-17
      • 2018-01-24
      • 2014-09-23
      • 1970-01-01
      相关资源
      最近更新 更多