LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MarginalMomentsFromWeightedTrace.m
1% moms = MarginalMomentsFromWeightedTrace(trace, weights, K)
2%
3% Returns the marginal moments of a trace consisting of
4% weighted data.
5%
6% Parameters
7% ----------
8% trace : vector of doubles
9% The trace data
10% weights : vector of doubles
11% The weights corresponding to the trace data
12% K : int
13% The number of moments to compute
14%
15% Returns
16% -------
17% moms : vector of doubles
18% The (raw) moments of the weighted trace
19
20function moms = MarginalMomentsFromWeightedTrace (trace, weights, K)
21
22 if nargin<2
23 K = 5;
24 end
25
26 moms = zeros(1,K);
27 for i=1:K
28 moms(i) = sum(dot(trace.^i,weights));
29 end
30 moms = moms / sum(weights);
31end