void FerNNClassifier::update(const vector<int>& fern, int C, int N) {
int idx;
for (int i = 0; i < nstructs; i++) {
idx = fern[i];
(C==1) ? pCounter[i][idx] += N : nCounter[i][idx] += N;
if (pCounter[i][idx]==0) {
posteriors[i][idx] = 0;
} else {
posteriors[i][idx] = ((float)(pCounter[i][idx]))/(pCounter[i][idx] + nCounter[i][idx]);
}
}
}
//训练集合分类器(n个基本分类器集合)
void FerNNClassifier::trainF(const vector<std::pair<vector<int>,int> >& ferns,int resample){
// Conf = function(2,X,Y,Margin,Bootstrap,Idx)
// 0 1 2 3 4 5
// double *X = mxGetPr(prhs[1]); -> ferns[i].first
// int numX = mxGetN(prhs[1]); -> ferns.size()
// double *Y = mxGetPr(prhs[2]); ->ferns[i].second
// double thrP = *mxGetPr(prhs[3]) * nTREES; ->threshold*nstructs
// int bootstrap = (int) *mxGetPr(prhs[4]); ->resample
//thr_fern: 0.6 thrP定义为Positive thershold
thrP = thr_fern * nstructs; // int step = numX / 10;
//for (int j = 0; j < resample; j++) { // for (int j = 0; j < bootstrap; j++) {
for (int i = 0; i < ferns.size(); i++){ // for (int i = 0; i < step; i++) {
// for (int k = 0; k < 10; k++) {
// int I = k*step + i;//box index