randg.m
来自「matlab算法集 matlab算法集」· M 代码 · 共 25 行
M
25 行
function A = randg (m,n,mu,sigma)
%-----------------------------------------------------------------------
% Usage: A = randg (m,n,mu,sigma)
%
% Description: Generate a matrix of random numbers with a
% Gaussian distribution
%
% Inputs: m = number of rows of A
% n = number of columns of A
% mu = mean of random numbers
% sigma = standard deviation of random numbers
%
% Outputs: A = m by n matrix of Gaussian random numbers
% with mean mu and standard deviation sigma
%-----------------------------------------------------------------------
x1 = randu (m,n,0,1);
x2 = randu (m,n,0,1);
A = sqrt(-2*log(x1)).*cos(2*pi*x2);
A = sigma*(A - mu);
%-----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?