您的位置:首页 > 编程语言 > C语言/C++

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

2014-12-20 00:00 288 查看
#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) ;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C语言 白噪声 高斯