確率分布関数のセットを作成するために使用される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テストを使用して、データが類似しているかどうかを判断するつもりです。したがって、この構造内の特定のビンの合計にアクセスして「距離」を計算しようとしています。次を使用して、その値にアクセスできるはずだと思いました。
((my_type)->pdf->sum+x)
Xはビン番号です。
しかし、これは私が何をしても常に0を返します、誰かが何か考えを持っていますか、何が間違っているのですか?
前もって感謝します
- - 編集 - -
これがpdf/ヒストグラムを扱う私のコードの抜粋です:
/* 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 */
}
}