LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_joint_marking.m
1function F = moment_joint_marking(f, p, dims)
2% F = moment_joint_marking(f, p, dims)
3%
4% Joint factorial moments of the per-class counts under multinomial marking.
5%
6% If a count N is marked independently, every event receiving class j with
7% probability p_j, then the per-class counts (N_1,...,N_d) have joint factorial
8% moments
9%
10% E[prod_j (N_j)_(a_j)] = (prod_j p_j^(a_j)) * f_(|a|)
11%
12% where f is the factorial moment sequence of the aggregate count N and
13% |a| = a_1+...+a_d. This is the counting-process counterpart of the marking
14% (class-splitting) formulas of the M3A fitters, and it is exact for the
15% per-class counts of a MAP marked in this i.i.d. way, in particular for an
16% MMAP whose marking probabilities do not depend on the phase.
17%
18% Input:
19% f: vector of length n+1 holding the factorial moments f_0,...,f_n of the
20% aggregate count
21% p: vector of length d holding the marking probabilities
22% dims: vector of length d holding the maximum order per class. Their sum
23% must not exceed n, since an entry of multi-order a consumes the
24% aggregate moment of order |a|
25%
26% Output:
27% F: array of size (dims(1)+1)x...x(dims(d)+1) holding the joint factorial
28% moments of the per-class counts
29%
30% Example:
31% F = moment_joint_marking([1, 2, 4, 8], [0.3, 0.7], [1, 1]);
32%
33% Reference:
34% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
35% distributions. PMCCS, 2003.
36
37fcol = f(:);
38pv = p(:).';
39dv = dims(:).';
40d = numel(pv);
41if numel(dv) ~= d
42 line_error(mfilename,'The vectors p and dims must have the same length.');
43end
44if any(dv < 0) || any(dv ~= round(dv))
45 line_error(mfilename,'The maximum orders must be nonnegative integers.');
46end
47if sum(dv) > length(fcol)-1
48 line_error(mfilename,'The aggregate factorial moments must reach order sum(dims).');
49end
50sz = dv + 1;
51nel = prod(sz);
52Fv = zeros(nel,1);
53a = ones(1,d);
54for ia = 1:nel
55 ord = a - 1;
56 Fv(ia) = prod(pv .^ ord) * fcol(sum(ord)+1);
57 for l = 1:d
58 a(l) = a(l) + 1;
59 if a(l) <= sz(l)
60 break
61 end
62 a(l) = 1;
63 end
64end
65F = reshape(Fv, [sz 1]);
66end