LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
PdfFromWeightedTrace.m
1% [x, y] = PdfFromWeightedTrace(trace, weights, intBounds)
2%
3% Returns the empirical density function of a trace
4% consisting of 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% intBounds : vector of doubles
13% The array of interval boundaries. The pdf is the
14% number of samples falling into an interval divided by
15% the interval length.
16%
17% Returns
18% -------
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
24
25function [x, y] = PdfFromWeightedTrace (trace, weights, intBounds)
26
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));
30 for i=1:length(x)
31 y(i) = sum(weights(and(trace>=intBounds(i),trace<intBounds(i+1))));
32 end
33 y = y ./ reshape(intlens,1,length(intlens)) / sum(weights);
34end