Digital Signal Processing Reference
In-Depth Information
4
3
0.2
2
0.15
1
0.1
0
0.05
-1
0
-2
4
2
4
-3
2
0
0.01
0
-2
-2
-4
-4
-4
-3
-2
-1
0
1
2
3
4
-4
y
D
x
x
Bild 14-5
Grafische Darstellung der zweidimensionalen WDF einer Normalverteilung (oben) und ihrer
Höhenlinien (unten) ( dsplab14_5 )
Programmbeispiel 14-2 Schätzung der zweidimensionalen WDF
% Estimation of the bidimensional probability density function (pdf)
% dsplab14_4.m * mw * 13Feb2011
N = 1e7; % number of samples
M1 = 30; M2 = 30; % number of bins for (1-dim.) pdfs 1 or 2
MIN1 = -4; MIN2 = -4; % minimum value of bin centers
MAX1 = 4; MAX2 = 4; % maximum value of bin centers
h2d = [M1,MIN1,MAX1,M2,MIN2,MAX2]; % parameter vector for function hist2
% 2-dim. histogram (absolute frequency)
x1 = randn(N,1);
x2 = randn(N,1) + x1;
[c1,c2,f2d] = hist2d(x1,x2,h2d);
% 2D histogram
% Normalization (pdf)
D1 = (MAX1-MIN1)/(M1-1);
% width of bins for x1
D2 = (MAX2-MIN2)/(M2-1);
% width of bins for x2
f2d = f2d/(D1*D2*N);
% normalization (relative frequency)
%% Graphics
FIG1 = figure( 'Name' , 'dsplab14_4 : bidimensional
pdf' , 'NumberTitle' ,...
'off' , 'Units' , 'normal' , 'Position' ,[.4 .4 .45 .45]);
surfl(c1,c2,f2d);
% pdf
xlabel( '{\itx} \rightarrow' ), ylabel( '\leftarrow {\ity}' )
zlabel( '{\itf}({\itx},{\ity}) \rightarrow' )
FIG2 = figure( 'Name' , 'dsplab14_4 : contour lines of bidim. pdf' ,...
'NumberTitle' , 'off' , 'Units' , 'normal' , 'Position' ,[.4 .37 .45 .45]);
V = [.01 .05 .10 .15 .2];
[CS,CH] = contour(c1,c2,f2d,V); grid
% contour lines
clabel(CS,CH,V);
xlabel( '{\itx} \rightarrow' ), ylabel( '{\ity} \rightarrow' )
Programmbeispiel 14-3 Bivariates Histogramm
function [c1,c2,f2d] = hist2d(x,y,h2d)
% Bivariate histogram with equidistant bin center spacing
% function [c1,c2,f2d] = hist2d(x,y,h2d)
% x : input sequence 1
% y : input sequence 2
% if y is scalar, y is used as shift parameter, i.e.
Search WWH ::




Custom Search