LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
EmpiricalSquaredDifference.m
1% sd = EmpiricalSquaredDifference(f1, f2, intBounds)
2%
3% Returns the squared difference of two continuous
4% functions given by samples and the bounds of the
5% corresponding intervalls.
6%
7% This function can be used to characterize the distance
8% between two density functions, distribution functions,
9% etc.
10%
11% Parameters
12% ----------
13% f1 : vector, length M
14% Samples of the first continuous function
15% f2 : vector, length M
16% Samples of the second continuous function
17% intBounds : vector, length M+1
18% The bounds of the intervals. The ith sample
19% corresponds to the interval
20% (intbounds(i),intbounds(i+1))
21%
22% Returns
23% -------
24% sd : double
25% The squared difference
26
27function sd = EmpiricalSquaredDifference (f1, f2, intBounds)
28
29 intlens = intBounds(2:end) - intBounds(1:end-1);
30 intlens = reshape(intlens, size(f1));
31 p1 = f1 .* intlens;
32 p2 = f2 .* intlens;
33 sd = SquaredDifference (p1, p2);
34end
35