1% [x, y] = PdfFromWeightedTrace(trace, weights, intBounds)
3% Returns the empirical density function of a trace
4% consisting of weighted data.
8% trace : vector of doubles
10% weights : vector of doubles
11% The weights corresponding to the trace data
12% intBounds : vector of doubles
13% The array of interval boundaries. The pdf
is the
14% number of samples falling into an interval divided by
19% x : vector of doubles
20% The center of the intervals (the points where the
21% empirical pdf
is calculated)
22% y : vector of doubles
23% The values of the empirical pdf at the given points
25function [x, y] = PdfFromWeightedTrace (trace, weights, intBounds)
27 intlens = intBounds(2:end) - intBounds(1:end-1);
28 x = reshape((intBounds(2:end) + intBounds(1:end-1)) / 2.0, 1, length(intlens));
29 y = zeros (1, length(intlens));
31 y(i) = sum(weights(and(trace>=intBounds(i),trace<intBounds(i+1))));
33 y = y ./ reshape(intlens,1,length(intlens)) / sum(weights);