hist_08.cc

来自「这是一个从音频信号里提取特征参量的程序」· CC 代码 · 共 88 行

CC
88 行
字号
// file: $isip/class/numeric/Histogram/hist_08.cc// version: $Id: hist_08.cc,v 1.1 2001/02/01 16:47:51 hamaker Exp $//// isip include files//#include "Histogram.h"// method: pdf//// arguments://  VectorDouble& pdf: (output) pdf of histogram data//// return: boolean value indicating status//// this method computes the probability density function given counts from// the histogram data//boolean Histogram::pdf(VectorDouble& pdf_a) const {  // make sure the histogram has been initialized  //  if ((bins_d.length() == 0) || (counts_d.length() != bins_d.length())) {    return Error::handle(name(), L"update", ERR_BINS, __FILE__, __LINE__);  }  // copy the counts over  //  pdf_a.assign(counts_d);  // divide by the sum of all counts  //  double sum = pdf_a.sum();  if (sum != 0) {    pdf_a.div(sum);  }    // exit gracefully  //  return true;}// method: cdf//// arguments://  VectorDouble& cdf: (output) cdf of histogram data//// return: boolean value indicating status//// this method computes the cumulative density function given counts from// the histogram data//boolean Histogram::cdf(VectorDouble& cdf_a) const {  // make sure the histogram has been initialized  //  if ((bins_d.length() == 0) || (counts_d.length() != bins_d.length())) {    return Error::handle(name(), L"update", ERR_BINS, __FILE__, __LINE__);  }  // copy the counts over  //  cdf_a.assign(counts_d);  // compute the cdf of the counts  //  double sum = cdf_a.sum();  long length = cdf_a.length();  for (long i = 1; i < length; i++) {    cdf_a(i) += cdf_a(i-1);  }  // normalize  //  if (sum != 0) {    cdf_a.div(sum);  }  // manually set the last bin  //  cdf_a(length - 1) = 1;    // exit gracefully  //  return true;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?