JuliaLang/julia — pull request #722 by carlobaldassi (2012-04-15 18:01:51+00:00)
Title: statistics.jl patches

I have made 2 patches to `statistics.jl` which I leave here for review/discussion.

The first one vectorizes most of the code. It gives huge speedups in the most important cases (standard numeric arrays, even sparse ones) and it seems to be faster anyway in all other cases. I think that the code is still sufficiently generic that any future proper AbstractArray implementation should provide an interface such that everything works as expected.

Note: the "spearman" variants of `cov` and `cor` were not working, and this patch desn't fix that, but the "`sub() act like ref()`" patch does (except for sparse arrays and bitarrays, for which `amap` is not defined).

The second patch adds an option not to use Bessel's correction, to all functions which use it (`var`, `std`, `cov`, `cor`). This was discussed in #711. It's done in a Matlab-friendly way, in that the option is a `Bool` which is `false` by default (yielding the current behaviour). The option name is `uncorr` (short for "uncorrected"): I don't like this name at all, but I couldn't come up with a better alternative (suggestions welcome).