I think Mike Day has the best approach, which is to refactor
the computation so you can use running sums.

You can calculate variance from running sums of the input
values and their squares.  This has pitfalls if the numbers
are big enough that the sum of the squares takes more than
53 bits, but depending on what your numbers are, if you
start by subtracting the mean of the overall dataset you
might make the values small enough that overflow is not a problem.

Or, you could factor the problem into two dimensions, first
calculating the variance of rows and then combining variances
of groups of rows, using the fact that the (variance of a group) =
(mean of the subgroup variances) + (variance of the subgroup means).

Henry Rich

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Brand
> Sent: Saturday, November 08, 2008 11:59 AM
> To: Programming forum
> Subject: Re: [Jprogramming] using ;. efficiently
> 
> That is a neater way to do it, but is a bit slower than ;. with the
> function stddev:
> 
> ts '; (1 1,:400,25)    (stddev@:,);._3  (i. 400 10000)'
> 4.13437 3.46953e7
> 
>    ts '25 (stddev@:,)\ |: (i.400 10000)'
> 4.60118 6.77667e7
> 
> On Sat, Nov 8, 2008 at 3:00 PM, Brian Schott 
> <[EMAIL PROTECTED]> wrote:
> > a4 =: 25+/\+/  (i. 400 20000)
> > 
> ----------------------------------------------------------------------
> > For information about J forums see 
> http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to