www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@candidateset/private/discrepancy.m

    function Var = discrepancy(X, NBoxes, BoxWidth)
%DISCREPANCY Calculate discrepancy of a point set.
%
%   VAR = DISCREPANCY(X, NBOXES, BOXWIDTH)

%   Copyright 2007 The MathWorks, Inc.


[NPoints, NFactors] = size(X);

% Generate random corners that are integers between 1 and (Width-BoxWidth)
Width = NPoints;
Corner = rand(NBoxes, NFactors);
Corner = 1+floor(Corner.*(Width-BoxWidth));

% Sort X and the boxes so we can break out of loops early when possible
[unused, idx] = sort(X(:,1));
X = X(idx,:);
[unused, idx] = sort(Corner(:,1));
Corner = Corner(idx,:);

Var = mx_discrepancy(X, Corner, BoxWidth);
return