3
두 변수 (X, Y)의 쌍이 주어지면 바닐라 MATLAB (도구 상자 없음)에서 경험적 관절 PDF 및 CDF를 어떻게 생성하고 플로팅 할 수 있습니까?경험적 공동 생성 및 그래프 PDF 파일
두 변수 (X, Y)의 쌍이 주어지면 바닐라 MATLAB (도구 상자 없음)에서 경험적 관절 PDF 및 CDF를 어떻게 생성하고 플로팅 할 수 있습니까?경험적 공동 생성 및 그래프 PDF 파일
데이터는 :
X
, Y
의 벡터로 정의 하였다.x_axis
, y_axis
의해 정의. 분명히 가장자리가 증가해야하지만 균일하게 간격을 둘 필요는 없습니다.결과 PDF 및 CDF는 x 및 y 에지에 의해 결정되는 직사각형의 중심에서 정의됩니다.
는 3D로 결과를 플롯surf(...)
대신
imagesc(...)
을 사용합니다.
clear all
%// Data (example):
X = randn(1,1e5); %// random variables.
Y = randn(1,1e5);
x_axis = -3:.2:3; %// Define edges of bins for x axis. Column vector
y_axis = -3:.2:3; %// Same for y axis
%// Compute corners of 2D-bins:
[x_mesh_upper,y_mesh_upper] = meshgrid(x_axis(2:end),y_axis(2:end));
[x_mesh_lower,y_mesh_lower] = meshgrid(x_axis(1:end-1),y_axis(1:end-1));
%// Compute centers of 1D-bins:
x_centers = (x_axis(2:end)+x_axis(1:end-1))/2;
y_centers = (y_axis(2:end)+y_axis(1:end-1))/2;
%// Compute pdf:
pdf = mean(bsxfun(@le, X(:), x_mesh_upper(:).') ...
& bsxfun(@gt, X(:), x_mesh_lower(:).') ...
& bsxfun(@le, Y(:), y_mesh_upper(:).') ...
& bsxfun(@gt, Y(:), y_mesh_lower(:).'));
pdf = reshape(pdf,length(x_axis)-1,length(y_axis)-1); %// pdf values at the
%// grid points defined by x_centers, y_centers
pdf = pdf ./ (y_mesh_upper-y_mesh_lower) ./ (x_mesh_upper-x_mesh_lower);
%// normalize pdf to unit integral
%// Compute cdf:
cdf = mean(bsxfun(@le, X(:), x_mesh_upper(:).') ...
& bsxfun(@le, Y(:), y_mesh_upper(:).'));
cdf = reshape(cdf,length(x_axis)-1,length(y_axis)-1);
%// Plot pdf
figure
imagesc(x_centers,y_centers,pdf)
axis xy
axis equal
colorbar
title 'pdf'
%// Plot cdf
figure
imagesc(x_centers,y_centers,cdf)
axis xy
axis equal
colorbar
title 'cdf'
matlab에 R2015b 모든 작업 histogram2
않는 기능을 포함한다. 그것은 자동으로 PDF (적절한 입력 플래그를 제공), 또는 심지어 CDF를 얻기 정상화 않습니다.
위와 같은 예제를 사용
clear all
%// Data (example):
X = randn(1,1e5); % random variables.
Y = randn(1,1e5);
x_axis = -3:.2:3; % Define edges of bins for x axis. Column vector
y_axis = -3:.2:3; % Same for y axis
%// Compute and plot pdf
figure
histogram2(X, Y, x_axis, y_axis, 'Normalization', 'pdf')
%// Compute and plot cdf
figure
histogram2(X, Y, x_axis, y_axis, 'Normalization', 'cdf')
은 "경험적 공동 PDF"무엇을 의미합니까? – Nick
좋아요, 그래서 저는 Google을 사용했습니다 : 경험적 합동 확률 밀도 함수! – Nick
이러한 변수는 어떻게 관련되어 있습니까? 여기에 더 많은 정보가 필요하다고 생각합니다. – MZimmerman6