2017-04-06 8 views

答えて

0

を意味し、1だから

pdf(x) = int(pdf(x | mean) * pdf(mean) dmean) 

を書くことができ、次のように、我々はMatlabの中でそれを計算することができます。

% define the constants 
sigma_x = 4; 
mu_mu = 2; 
sigma_mu = 8; 

% define the pdf of a normal distribution using the Symbolic Toolbox 
% to be able to calculate the integral 
syms x mu sigma 
pdf(x, mu, sigma) = 1./sqrt(2*pi*sigma.^2) * exp(-(x-mu).^2/(2*sigma.^2)); 

% calculate the desired pdf 
pdf_x(x) = int(pdf(x, mu, sigma_x) * pdf(mu, mu_mu, sigma_mu), mu, -Inf, Inf); 
pdfCheck = int(pdf_x, x, -Inf, Inf) % should be one 

% plot the desired pdf (green) and N(2, 4) as reference (red) 
xs = -40:0.1:40; 
figure 
plot(xs, pdf(xs, mu_mu, sigma_x), 'r') 
hold on 
plot(xs, pdf_x(xs), 'g') 

私は、計算されたpdfの積分が実際にはpdfであるために必要な条件である1に等しいことも確認しました。

enter image description here

緑のプロットは、要求されたPDFファイルです。赤のプロットは参照として追加され、一定の平均(平均平均に等しい)のpdfを表します。

+0

ありがとうございます;私は3Dのrepresantationを取得しようとしていた。 – EKtee

関連する問題