在matlab中生成随机噪声

发布于 2024-09-11 16:54:58 字数 137 浏览 5 评论 0原文

当我向数组添加高斯噪声时,直方图不应该是高斯的吗?虽然噪声是随机的,但分布应该是高斯分布,对吗?那不是我得到的。

A=zeros(10);
A=imnoise(A,'gaussian');
imhist(A)

When I add Gaussian noise to an array shouldnt the histogram be Gaussian? Although the noise is random, the distribution should be gaussian right? That is not what I get.

A=zeros(10);
A=imnoise(A,'gaussian');
imhist(A)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清浅ˋ旧时光 2024-09-18 16:54:59

这就是你的代码正在做的事情:

A = zeros(10);

mu = 0; sd = 0.1;                 %# mean, std dev
B = A + randn(size(A))*sd + mu;   %# add gaussian noise

B = max(0,min(B,1));              %# make sure that 0 <= B <= 1

imhist(B)                         %# intensities histogram

你能看出问题出在哪里吗? (提示:RANDN 返回数字 ~N(0,1),因此最终添加的噪声为 ~N(mu,sd)


也许您想要做的是:

hist( randn(1000,1) )

直方图

This is what your code is doing:

A = zeros(10);

mu = 0; sd = 0.1;                 %# mean, std dev
B = A + randn(size(A))*sd + mu;   %# add gaussian noise

B = max(0,min(B,1));              %# make sure that 0 <= B <= 1

imhist(B)                         %# intensities histogram

can you see where the problem is? (Hint: RANDN returns number ~N(0,1), thus the resulting added noise is ~N(mu,sd))


Perhaps what you are trying to do is:

hist( randn(1000,1) )

histogram

时光病人 2024-09-18 16:54:59

imnoise() 是一个可以应用于图像的函数,而不是普通数组。
也许您可以查看 randn() 函数。

imnoise() is a function that can be applied to images, not plain arrays.
Maybe you can look into the randn() function, instead.

被你宠の有点坏 2024-09-18 16:54:59

您可能看不到采样框仅为 10 的钟形曲线。

请参阅中心极限定理。

http://en.wikipedia.org/wiki/Central_limit_theorem

我会尝试增加采样框架到更大的东西。


参考

大数定律

http://en.wikipedia.org/wiki /大数法则

You might not see a bell-curve with a sampling frame of only 10.

See the central limit theorem.

http://en.wikipedia.org/wiki/Central_limit_theorem

I would try increasing the sampling frame to something much larger.


Reference:

Law of Large Numbers

http://en.wikipedia.org/wiki/Law_of_large_numbers

莫言歌 2024-09-18 16:54:58

可能会发生两件事:

  1. 您没有足够的样本量,或者

  2. 高斯分布的无噪声的默认均值是0,意味着您只能看到钟形曲线的右半部分。

尝试

imhist(imnoise(zeros(1000), 'gaussian', 0.5));

Two things could be going on:

  1. You don't have enough of a sample size, or

  2. The default mean of imnoise with gaussian distribution is 0, meaning you're only seeing the right half of the bell curve.

Try

imhist(imnoise(zeros(1000), 'gaussian', 0.5));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文