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

📄 randsph.m

📁 模式识别工具箱,希望对大家有用!
💻 M
字号:
function x = randsph(n,d)
%RANDSPH generate objects in hypersphere
%
% x = randsph(n,d)
%
% Generate n data objects uniformly drawn from a d-dimensional hypersphere
% with zero mean and unit radius.

% Copyright: D. Tax, R.P.W. Duin, davidt@ph.tn.tudelft.nl
% Faculty of Applied Physics, Delft University of Technology
% P.O. Box 5046, 2600 GA Delft, The Netherlands

% Gaussian data:
x = randn(n,d);
% squared norms of the vectors:
nx = sum(x.*x,2);
% make squared norms uniformly distributed:
if exist('mychi2cdf')  % necessary when you have your own copy of
                       % chi2cdf
  rx = mychi2cdf(nx,d);
else
  rx = chi2cdf(nx,d);
end
% change uniform to r^d
newrx = rx.^(2/d);

% renormalize the original data x:
x = sqrt(newrx./nx)*ones(1,d).*x;

⌨️ 快捷键说明

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