I am trying to compute the cumulative distribution function for a set of values.
I computed the histogram using gsl and I tried to computed the CDF from here, but it seems like the values are shifted by one position.
This is the code I am using:
gHist = gsl_histogram_alloc((maxRange - minRange) / 5);
gsl_histogram_set_ranges_uniform(gHist, minRange, maxRange);
for (int j = 0; j < ValidDataCount; j++)
gsl_histogram_increment (gHist, ValAdd[j]);
gsl_histogram_pdf * p = gsl_histogram_pdf_alloc(gsl_histogram_bins(gHist));
gsl_histogram_pdf_init (p, gHist);
for (int j = 0; j < gsl_histogram_bins(gHist) + 1 ; j++)
printf ("%f ", p->sum[j]);
The histogram is like this: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 .... goes on like this. there is a total of 20 values
And the cdf is: 0.00 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.1 0.1 ...
Why is there a 0 on the first position? Shouldn't it start with 0.05?
Thank you.