KDE Toolbox for MATLAB

来源:互联网 发布:gps转百度地图坐标 js 编辑:程序博客网 时间:2024/06/05 20:59

The KDE class is a general matlab class for k-dimensional kernel density estimation.
1,由于It is written in a mix of matlab “.m” files and MEX/C++ code. Thus, to use it you will need to be able to compile C++ code for Matlab. Note that the default compiler for Windows does not support C++, so you will need GCC or Visual C++ for Windows.
即,首先要下载并安装winsdk,tmd64-gcc-5.1.0-2,mingw-w64-install,gunmex。
2,由于在主页面http://www.ics.uci.edu/~ihler/code/kde.html下载的kde工具箱解压后是@kde,即一个类文件,不能够直接添加到路径下,需要放在一个文件夹下,然后添加该文件夹,如H:\work\KDEToolbox。
3,首先Compile the MEX functions. This can be done by going to the “@kde/mex” directory in Matlab, and copying and pasting the code from the “makemex.m” file into the Matlab window. 需要把mex文件夹的路径设置成当前路径:
这里写图片描述
4,在mex过程中出现错误:
这里写图片描述
在BallTreeDensityClass.cc中的第470行, type = (BallTreeDensity::KernelType)(mxGetScalar(mxGetField(structure,0,”type” )));
由于VS2013不支持枚举类型和double类型数的直接转化,因此在编译时会报错,可以先将double类型强制转化为int类型,然后再转化到枚举类型,即:type = (BallTreeDensity::KernelType) ((int)mxGetScalar(mxGetField
(structure, 0,”type”)));
这里写图片描述
在prodSampleGibbsMS.cpp、prodSampleGibbsMS2.cpp、entropyGradISE.cpp等多个文件中,存在log函数和pow函数重载的问题,导致编译无法通过,因此可在相应函数处将数据进行强制转换,我将其转化为double类型,可以根据实际要求进行强制转换, 即:
Nlevels = (unsigned int) (log((double)maxNp)/log(2.0))+1;
double Cnorm = 1.0 / (pow(pi, ((double)Nd) / 2)*pow(2, (double)Nd + 1));等;;

原创粉丝点击