Rambling from a WebDevel

Artscribing – artscribing is the art of creating meaning for and/or describing pieces of art, specially for abstract modern pieces that don’t have any apparent visual resemblance with pre-existing things.

In a less formal way, what it really means is taking some meaning or description for a piece of art out of one’s ass.

Just because I keep forgetting it and having to find out all the math manually again!

Average without keeping totals

Perl

1

2

3

4

5

6

7

8

9

10

11

my$avg=0;

my$cnt=0;

formy$row(@rows){

if($cnt){

$avg+=(($row->{value}-$avg)/($cnt+$row->{cnt}))*$row->{cnt};

$cnt+=$row->{cnt};

}else{

$cnt=$row->{cnt};

$avg=$row->{value};

}

}

The two main reasons to use something like this is if your total is too big and you don’t care about standard deviations – I’m pretty sure we can come up with a streaming formula for the standard deviation as well.

Also, if you @rows is some type of stream in which you have a way to get the next value and you want to know the average so far at any given point, this is the way to do it.