On 5 Dec 2007, at 00:56, Surjit Nameirakpam wrote:

> How to calculate variance on the elements of an Array

*Shameless plug and probably overkill if you just want the variance*

RSRuby allows you to use any R function, including the built-in  
variance function ('var'). It's available as a gem.

irb(main):002:0> require 'rsruby'
=> true
irb(main):004:0> RSRuby.instance.var([1,2,3])
=> 1.0
irb(main):006:0> RSRuby.instance.var(RSRuby.instance.rnorm(10))
=> 0.812117410016217
irb(main):008:0> RSRuby.instance.var(RSRuby.instance.rnorm(100))
=> 0.960224242747171

Alex Gutteridge

Bioinformatics Center
Kyoto University