LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
CheckMoments.m
1% r = CheckMoments(m, prec)
2%
3% Checks if the given moment sequence is valid in the sense
4% that it belongs to a distribution with support (0,inf).
5%
6% This procedure checks the determinant of `\Delta_n`
7% and `\Delta_n^{(1)}` according to [1]_.
8%
9% Parameters
10% ----------
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.
18%
19% Returns
20% -------
21% r : bool
22% The result of the check.
23%
24% References
25% ----------
26% .. [1] http://en.wikipedia.org/wiki/Stieltjes_moment_problem
27
28function r = CheckMoments (m, prec)
29
30 global BuToolsCheckInput;
31 if isempty(BuToolsCheckInput)
32 BuToolsCheckInput = true;
33 end
34 global BuToolsCheckPrecision;
35 if isempty(BuToolsCheckPrecision)
36 BuToolsCheckPrecision = 1e-14;
37 end
38
39 if ~exist('prec','var')
40 prec=BuToolsCheckPrecision;
41 end
42
43 if BuToolsCheckInput && mod(length(m),2)==0
44 error ('CheckMoments: the number of moments must be odd!');
45 end
46
47 m = reshape(m, 1, length(m));
48 m = [1.0 m];
49 N = floor(length(m)/2)-1;
50
51 for n=0:N
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
55 r = false;
56 return;
57 end
58 end
59 r = true;
60end
61