root/applications/bdmtoolbox/mex/epdf_2dplot.m @ 1324

Revision 809, 1.1 kB (checked in by smidl, 15 years ago)

Bhattacharyya pro Ivana

Line 
1function [X,Y,Z]=epdf_2dplot(pdf,xlims,ylims, points)
2% function evaluates given pdf on support
3%  xlims = [x_begin, x_end] --or-- empty
4%  ylims = [x_begin, x_end] --or-- empty
5%  points = if not given, 100
6
7if nargin<4
8    points = [100,100];
9end
10
11if length(points) ==1
12    points = points*[1 1];
13end
14
15if nargin<3 | isempty(ylims)
16    p_mean = epdf_mean(pdf);
17    p_var  = epdf_variance(pdf);
18    ylims = p_mean(2)*[1 1] + [-3 3]*sqrt(p_var(2));
19end
20if nargin<2 | isempty(xlims)
21    p_mean = epdf_mean(pdf);
22    p_var  = epdf_variance(pdf);
23    xlims = p_mean(1)*[1 1] + [-3 3]*sqrt(p_var(1));
24end
25
26steps = [xlims(2)-xlims(1), ylims(2)-ylims(1)];
27[X,Y]=meshgrid(xlims(1):steps(1)/(points(1)-1):xlims(2), ...
28                ylims(1):steps(2)/(points(2)-1):ylims(2));
29data = [reshape(X, 1, prod(points)); reshape(Y,1,prod(points))];
30v = epdf_evallog_mat(pdf,data);
31Z = reshape(exp(v), points(1), points(2));
32
33if 0
34    vol = prod(steps./(points-1));
35    nc = sum(sum(Z))*vol
36    % renormalize
37    p = exp(v)/nc;
38    num_mean = vol*data*p
39    num_cov = vol*data*(p*ones(1,2).*data') - num_mean * num_mean'
40end
41contour(X,Y,Z);
Note: See TracBrowser for help on using the browser.