This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gsl_histogram_sum proposal


Brian Gough wrote:
> 
> Achim Gaedke writes:
>  > Here is a proposal for an additional function in histogram/stat.c:
>  >  double gsl_histogram_sum(gsl_histogram * h)
>  >  Using gsl_histogram_increment() it gives you the number of
>  > samples, you have added to the histogram. Maybe someone is missing
>  > it, too.
> 
> That looks fine.  If you can send me a complete patch for 1d/2d
> histograms and documentation I'll add it straight in.
> 
> Brian


I have a trivial comment. But, after all, my forte is trivial
interface issues. It would probably be better to have something
like the following.

double 
gsl_histogram_sum(gsl_histogram * h, size_t i_begin, size_t i_end)
{
  double sum = 0;
  size_t i;

  i_begin = ( i_begin > h->n ? h->n : i_begin );
  i_end   = ( i_end > h->n ? h->n : i_end );

  for (i = i_begin; i < i_end; i++)
    {
      sum += h->bin[i];
    }

  return sum;
}


Once the desire comes to sum from 0 to n, the desire
to sum with arbitrary limits will surefly follow.


-- 
G. Jungman


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]