C语言和数字信号处理

手头一份  :  数字信号处理C语言程序集 
作者    殷福亮 宋爱军 出版社 辽宁科学技术出版社   出版日期 1997年7月第1版 打算每一个周末花一段时间学学.

编译工具 vc2008

下面是概率统计的链接:

北京工业大学概率统计

south china university of tech 

同余随机序列

1 uniform 均匀分布随机数生成c语言:

uniform h文件

#ifndef _UNIFORM_H_
#define _UNIFORM_H_
double uniform(double a, double b,long int *seed);
void uniform_test(void);
#endif

uniform c文件

#include "uniform.h"
#include "stdio.h"
#define Lamda  2045
#define Miu    1
#define M      1048576
double uniform(double a, double b,long int *seed)//混合同余法
{
   double t;
   *seed= Lamda*(*seed)+Miu;
   *seed=*seed-(*seed/M)*M;//对M同余运算
   t=(*seed)/(M+0.0);
   t=a+(b-a)*t;
   return(t);
}
void uniform_test(void)
{
   double a =0.0;
   double b =1.0;
   double x;
   long int s=13579;
   int i,j;
   printf("\n  uniform test start!\n");
   for(i=0;i<10;i++)
   {
       for(j=0;j<5;j++)
       {
           x=uniform(a,b,&s);
           printf("  %13.7f",x);
       }
       printf("\n");
   }

}

//

#include"uniform.h"

#include"main.h"

void main(void)
{
   uniform_test();
   //gauss_test();
}

  uniform test start!
      0.4826355      0.9895945      0.7206707      0.7715826      0.8864250
      0.7391634      0.5891514      0.8145781      0.8121262      0.7979975
      0.9048367      0.3909597      0.5126686      0.4073076      0.9440937
      0.6716261      0.4753571      0.1051798      0.0926647      0.4993505
      0.1718712      0.4765749      0.5956669      0.1387815      0.8082657
      0.9033289      0.3075924      0.0264425      0.0749702      0.3141527
      0.4423084      0.5207319      0.8967896      0.9346323      0.3230572
      0.6519232      0.1829033      0.0372286      0.1324558      0.8721647
      0.5768661      0.6912775      0.6624966      0.8054800      0.2066078
      0.5129900      0.0645466      0.9977674      0.4344330      0.4154520
请按任意键继续. . .

原文地址:https://www.cnblogs.com/fleetwgx/p/1795324.html