C语言利用瑞丽分布产生高斯白噪声

#include<windows.h>
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<math.h>
#define N_gauss 1000 //需要产生的高斯白噪声序列的点的个数

double *gauss(double ex,double dx,int n_point)//ex:均值;dx:方差;n_point:点数
{ 
	time_t t;
	int i;
	double *mem1;
	mem1 = (double *)malloc(n_point*sizeof(double));
	srand((unsigned)time(&t));
	for(i=0;i<n_point;i++)
		mem1[i]=(sqrt(-2*log((double)rand()/32768))*cos((double)rand()/32768*2*3.1415926))*sqrt(dx)+ex;
	return(mem1);
}

void main(){
	float ex =0.0  ;
	float dx = 1.0 ;
	double *mem1 = gauss(ex, dx, N_gauss) ;

}
 

转载于:https://my.oschina.net/itfanr/blog/195614

猜你喜欢

转载自blog.csdn.net/weixin_33938733/article/details/91799577