simlinear.m

来自「用matalab开发的随机数生成程序包」· M 代码 · 共 30 行

M
30
字号
function [sample] = simlinear(M, N)
%
% [sample] = simlinear(M, N)
%
% Generate a matrix of random numbers from the "linear"
% distribution with 
%
% pdf      f(x) = 2-2*x,  0<=x<=1,
%
%                 /0,       x<=0
% cdf      F(x) = |2*x-x^2, 0<=x<=1
%                 \1,       x>=1
%
% It is the stationary distribution for the uniform (0, 1)
% distribution:
%         F(x) = 1/mu * int_0^x (1-F_U(y)) dy
%
% Inputs:
%        M - number of rows in the output matrix
%        N - number of columns in the output matrix
%
% Outputs:
%        sample - MxN matrix of random numbers
%

% Authors: R.Gaigalas, I.Kaj
% v1.0 15-Nov-05

  sample = 1-(1-rand(M, N)).^0.5;

⌨️ 快捷键说明

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