rand_uniform_inside_hypersphere.m
来自「一个用EM算法的源程序」· M 代码 · 共 15 行
M
15 行
function X = rand_uniform_inside_hypersphere(ambientDimension, sampleCount)% Generate sampleCount points sampled uniformly from within a unit hypersphere% lying in an ambient space of dimension ambientDimension.% Columns of X are data points.% There are ways of doing this that don't require the computation of so% many random numbers. There is an article from the seventies on how% to do this written in an era where this sort of thing took hours on% contemporary hardware.X = rand(ambientDimension, sampleCount)-0.5*ones(ambientDimension,sampleCount);norms = sqrt(sum(X.*X,1));radii = rand(1, sampleCount).^(1/ambientDimension);X = X * diag(sparse(radii./norms));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?