在C频率直方图 [英] Frequency Histogram in C

查看:96
本文介绍了在C频率直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我一个直方图的伪code会怎么看起来像一个暗示?

can someone give me a hint on how a histogram's pseudo code would look like?

推荐答案

如何构建并填写直方图?

How to structure and fill a histogram?

简单的情况就是每个二进制计数:

Trivial case is just a count per bin:

/* needs error checking, badly */
int *buildHist(int bins, double min, double max, int n, double *data){
   double *hist=malloc(bins*sizeof(int));
   if (hist == NULL) return hist;
   for (int i=0; i<n; ++i){
      int bin=int( (data[i]-min)/((max-min)/(bins)) );
      if ( (bin>=0) && (bin<n) ) hist[bin]++;
   }
   return hist;
}

有关的加权直方图,数组必须是浮点类型的。

For a weighted histogram, the array must be of floating point type.

随着越来越多的数据(大于和小于流计数,累加统计......甚至保持在同一个地方作为计数的限制),使用包括阵列的结构。

With more data (over- and under-flow counts, accumulated statistics...or even to keep the limits in the same place as the count), use a structure that includes the array.

增量填充经常需要的,但应该是显而易见的,从这里。

Incremental filling is often desired, but should be obvious from here.

输出取决于大量你手头有什么样的显示技术。

Output depends a great deal on what display technology you have at hand.

这篇关于在C频率直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆