uniform_random.m

来自「This a collection of MATLAB functions fo」· M 代码 · 共 14 行

M
14
字号
function s = uniform_random(N)
%function s = uniform_random(N)
%
% Generate N uniform-random numbers within interval (0,1) in ascending order.
% Adapted from Doucet & de Feitas' high speed Niclas Bergman Procedure.
%
% Tim Bailey 2005.

s = fliplr(cumprod(rand(1,N).^(1./(N:-1:1))));

% Alternatively, a solution of my own devising (TB, 2006). But is it uniform-random?
%s = cumsum(rand(1,N));
%s = s ./ (s(end)+rand(1));

⌨️ 快捷键说明

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