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

📄 randsph.m

📁 SVDD的工具箱
💻 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.
%
% See also: gendatout

% Copyright: D.M.J. Tax, D.M.J.Tax@prtools.org
% Faculty EWI, Delft University of Technology
% P.O. Box 5031, 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 I use my own copy of
							  % chi2cdf
	rx = mychi2cdf(nx,d);
else
	rx = chi2cdf(nx,d);
end
% Change uniform distribution to r^d
newrx = rx.^(2/d);

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

return

⌨️ 快捷键说明

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