2021-07-25科研之kde

matlab

pd = fitdist(x,distname)
对数据进行概率分布对象拟合/Fit probability distribution object to data
注意只限于一维 x: N*1

同ksdensity()
注意:同样限于一维

多维kde
kde toolbox,且需GCC
解决
说明文档页

bw选择方法
MISE准则
MISE准则 matlab自写code

wikipedia page中详细(见下)

n-dimensional data


4. \color{blue}{4.} 4.
1-dimensional data: kernel dis方式

SixMPG = [13;15;23;29;32;34];
figure
histogram(SixMPG)

%kde拟合得到kernel distribution
pd_kernel = fitdist(data,'Kernel','BandWidth',4);
%or
pd_kernel = fitdist(x,'Kernel','Kernel','epanechnikov')
%Define the x values and compute the pdf of each distribution.
x = 50:1:250;
pdf_kernel = pdf(pd_kernel,x);
%Plot the pdf of each distribution.
plot(x, pdf_kernel, 'Color','b','LineWidth',2);
legend('Kernel Dis')
%附录:Kernel- Kernel smoother type
% normal, box, triangle, epanechnikov

1-dimensional data:ksdensity方式

SixMPG = [13 5 3;15 8 5;12 5 6];
x=[1 6;3 8;3 10;2 8];
x1=[11 2;7 3;1 8;9 8];
x=[1 6 9];

[f,xi] = ksdensity(SixMPG,x,'Bandwidth',4); 
[f_1,xi_1,bw_1] = ksdensity(SixMPG); 
[f_2,xi_2,bw_2] = ksdensity(SixMPG,x1);

5. \color{red}{5.} 5.
adaptive Kernel Density Estimator for High Dimensions 直接.m函数使用,无需按照mex这些鬼

记录一些快速回顾使用方式
%说明:grid:带进去compute pdf的points; Example中为了plot,所以grid费了一定功夫
%要求:data:Nd grid:Md
%pdf=akde(data,grid); % run adaptive kde

6    老 师 分 享 \color{red}{6\ \ 老师分享} 6  
可多维kde

你可能感兴趣的:(Matlab,科研)