From: "NARUSE, Yui" Date: 2009-11-08T03:41:40+09:00 Subject: [ruby-core:26596] Re: Add Standard Deviation Function to Math Module Daniel Cohen wrote: > I am attaching a preliminary version of the statistics module. It > implements both kinds of standard deviation, as well as generating > random numbers and finding values for a normal distribution among other > things. > > I am currently working on a feature to perform linear curve fitting or > regression on a set of points, however, I am running into trouble on how > to sum the products of the x and y. For example, I have two enumerations > xlist and ylist. Both are the same length. I want to multiply each pair > and then add them to the running total. For example, (x1 * y1) + (x2 * > y2) + ... for however many pairs I have. Any suggestions on how to do > this cleanly would be much appreciated. > > The odd include for ruby.h is specific to my development environment. I'm not a statistics people but some thought about it. First this argument is enum, but it should receive Typed Array as Float (or Narray.float(size)) for optimization. People who use Statistics hate its large number of NUM2DBL and moreover calling each methods, doesn't they? If it uses enum as argument, it must call Enumerable#enum. This means this Statistics library can't run in parallel. Second is Statistics.rand(). Don't call srand if you want random value. This implementation allow users to guess the return value by time. Simply call rb_f_rand() seems good. And stat_cdf's implementation is broken. -- NARUSE, Yui