1% r = CheckMoments(m, prec)
3% Checks
if the given moment sequence
is valid in the sense
4% that it belongs to a distribution with support (0,inf).
6% This procedure checks the determinant of `\Delta_n`
7% and `\Delta_n^{(1)}` according to [1]_.
11% m : list of doubles, length 2N+1
12% The (raw) moments to check
13% (starts with the first moment).
14% Its length must be odd.
15% prec : double, optional
16% Entries with absolute value less than prec are
17% considered to be zeros. The default value
is 1e-14.
22% The result of the check.
28function r = CheckMoments (m, prec)
30 global BuToolsCheckInput;
31 if isempty(BuToolsCheckInput)
32 BuToolsCheckInput =
true;
34 global BuToolsCheckPrecision;
35 if isempty(BuToolsCheckPrecision)
36 BuToolsCheckPrecision = 1e-14;
39 if ~exist(
'prec',
'var')
40 prec=BuToolsCheckPrecision;
43 if BuToolsCheckInput && mod(length(m),2)==0
44 error ('CheckMoments: the number of moments must be odd!');
47 m = reshape(m, 1, length(m));
49 N = floor(length(m)/2)-1;
52 H = hankel(m(1:n+1), m(n+1:2*n+1));
53 H0 = hankel(m(2:n+2), m(n+2:2*n+2));
54 if det(H)<-prec || det(H0)<-prec