⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gngauss.m

📁 TCM的仿真 包括编码器
💻 M
字号:
function[gsrv1,gsrv2]=gngauss(m,sgma) %  高斯随机变量1,高斯随机变量2,发生器generate %   I was asked to realize the gaussian distribution,which may be generated by the matlab function randn,normrnd......  %   but it is still necessary to know how to realize it just by uniform random numbers in (0,1).  %   here is a way.for simplicity I suppose sigma=1 and u=0,the standard normal distribution.   %   we should know that we can not give the analystic equation of the probabilty distrbution function of  gaussian distribution.  %   but we know that R(x)=1-exp(-x^2/(2*sigma^2)) when x>=0 and R(x)=0 when x<0.R(x) is the probability distribution function of relay distribution.   %   and the gaussian distribution has the following relationship:  %  c=x*cos(theta)  %  d=x*sin(theta)  %  where c,d are two gaussian variables,x is the variable in the former function.  %  theta is the random variable in the uniform distribution of(0,2*pi).  %  if we have R(x)=A,A is uniformly distributed in (0,1)  %  then x= sqrt(2*sigma^2*ln(1/1-A)).  %  and another variable B uniformly distributed in (0,1),suppose  %  theta=2*pi*B  %  then we have two statically independent gaussian random variables c ,d .  %  if you want to have more variables,just to make A ,B vectors.  %  the realization:   %  m=0; sgma=1;  %  N=1000;  %  u=rand(1,N);  %  %  z=sgma*(sqrt(2*log(1./(1-u))));  %  u=rand(1,N);  %  gsrv2=m+z.*sin(2*pi*u);  %  gsrv1=m+z.*cos(2*pi*u);  %  g=[gsrv1,gsrv2];  %  hist(g);   %  if the gaussian distribution is not standard, just to change m and sigma.    if nargin==0, 	m=0;sgma=1; elseif nargin==1, 	sgma=m;m=0; end;  u=rand; z=sgma*(sqrt(2*log(1/(1-u)))); u=rand; gsrv1=m+z*cos(2*pi*u); gsrv2=m+z*sin(2*pi*u); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -