编制高斯噪声程序问题
谁有用matlab 自己产生的高斯分布噪声的程序啊??不是用自带函数生成的那种。。。。在这里先谢过了 即便有大多也是基于matlab中的平均序列生成的我有用Fortran 编的,你改为matlab 吧
!! Function to Return a Gaussian Noise with Mean u and Variance gReal Function GaussianNoise(u,g)
USE PORTLIB
Real u,g
Integer n
Real b
n=12 ; b=0.0
do i=1,n
b=b+RANDOM(0)
enddo
GaussianNoise = u+g*(b-n/2)
Return
End Function GaussianNoise
!! Function to Return a Gaussian Noise (0,1) based on Box-Muller Method ----
Real Function Gasdev()
USE PORTLIB
USE MSFLIB
Real x1, x2, x3, f1
if( jf_set == 0 ) then
10x1 = 2.0 * RANDOM(0) - 1.0
x2 = 2.0 * RANDOM(0) - 1.0
x3 = x1 * x1 + x2 * x2
if( x3 > 1.0 .OR. x3 == 0.0 ) goto 10
f1 = SQRT( -2.0 * log( x3 ) / x3 )
noise_set = x1 * f1
jf_set = 1
GASDEV = x2 * f1
else
jf_set = 0
GASDEV = noise_set
endif
Return
End Function Gasdev
页:
[1]