checksizes.m

来自「duke的tutorial on EM的matlab经典源码」· M 代码 · 共 39 行

M
39
字号
function [N, D, K] = checkSizes(x, p, m, sigma)

% Number of data points and space dimension
if max(size(x)) == 1
    % x is really N
    N = x;
    D = [];
else
    N = size(x, 2);
    D = size(x, 1);
end

% Number of mixture components
if max(size(p)) == 1
    % p is really K
    K = p;
else
    K = length(p);
end

% Check input sizes
if ~isempty(D)
	if size(m, 1) ~= D
        error('Means and data points must have the same number of dimensions')
	end
end
if size(m, 2) ~= K
    error('The number of means must equal the number of mixing probabilities')
end

if nargin >= 4
	if min(size(sigma) ~= 1)
        error('Only isotropic Gaussians are allowed')
	end
	if length(sigma) ~= K
        error('The number of standard deviations must equal the number of mixing probabilities')
	end
end

⌨️ 快捷键说明

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