【发布时间】:2012-08-03 07:05:33
【问题描述】:
我有一组 GSL 直方图,用于制作一组概率分布函数,根据文档存储在一个结构中,如下所示:
Data Type: gsl_histogram_pdf
size_t n
This is the number of bins used to approximate the probability distribution function.
double * range
The ranges of the bins are stored in an array of n+1 elements pointed to by range.
double * sum
The cumulative probability for the bins is stored in an array of n elements pointed to by sum.
我打算使用 KS 测试来确定数据是否相似。因此,我正在尝试访问此结构中给定 bin 的总和,以计算“距离”,并且我认为,我应该能够通过以下方式访问该值:
((my_type)->pdf->sum+x)
其中 X 是 bin 编号。
然而,无论我做什么,这总是返回 0,有没有人知道,出了什么问题?
提前致谢
---- 编辑----
这是我处理 pdf / 直方图的代码的 sn-p:
/* GSL Histogram creation */
for (i = 0; i < chrom->hits; i++) {
if ( (chrom+i)->spectra->peaks != 0 ) {
(chrom+i)->hist = gsl_histogram_alloc(bins);
gsl_histogram_set_ranges_uniform((chrom+i)->hist, low_mz, high_mz);
for (j = 0; j < (chrom+i)->spectra->peaks; j++) {
gsl_histogram_increment( (chrom+i)->hist, ((chrom+i)->spectra+j)->mz_value);
}
} else {
printf("0 value encountered!\n");
}
}
/* Histogram probability distribution function creation */
for (i = 0; i < chrom->hits; i++) {
if ( (chrom+i)->spectra->peaks != 0 ) {
(chrom+i)->pdf = gsl_histogram_pdf_alloc(bins);
gsl_histogram_pdf_init( (chrom+i)->pdf, (chrom+i)->hist);
} else {
continue;
}
}
/* Kolmogorov-Smirnov */
float D;
for (i = 0; i < chrom->hits-1; i++) {
printf("%f\n",((chrom+i)->pdf->sum+25));
for (j = i+1; j < chrom->hits; j++) {
D = 0;
diff = 0;
/* Determine max distance */
}
}
【问题讨论】:
-
我也这么认为,但它从不包含值,据我所知,测试 PDF 是否首先制作的唯一方法是使用返回值的“gsl_histogram_pdf_sample”函数。 ..
-
在访问上述变量之前,您是否尝试过 gsl_histogram_pdf_alloc() 和 gsl_histogram_pdf_init()?
-
我做了,我会在原始问题中发布我现在拥有的整个 sn-p