**Ja**va

**Ma**trix package. We just finished porting it over to PHP over at phpMath.com, and the results are pretty cool. Anyone who's ever done clickstream modelling or any sort of complex online data analysis will really benefit from this package too. Just a few examples:

function polyfit($X, $Y, $n) { if(count($X)!=count($Y) || count($X) < $n) return false; for ($i = 0; $i < sizeof($X); $i++) for ($j = 0; $j <= $n; $j++) $A[$i][$j] = pow($X[$i], $j); for ($i=0; $i < sizeof($Y); $i++) $B[$i] = array($Y[$i]); $matrixA = new Matrix($A); $matrixB = new Matrix($B); return $matrixA->solve($matrixB); }

$a = new Matrix(array(array(1, 0), array(0, 1)));

$ai = $a->inverse();

$sqadet = sqrt(pow(2*pi(), 2) * $a->det());

$mu = new Matrix(1, 2, 0);

for($i = 0; $i < 1; $i += 0.1) {

$y = new Matrix(array(array_fill(0, 2, $i)));

$y->minusEquals($mu);

$yt = $y->transpose();

$y = $y->times($ai);

$y = $y->times($yt);

$Q = -$y->get(0, 0) / 2;

echo exp($Q)/$sqadet . '

';

}

</pre>

We're also doing some work on implementing a complete statistical distribution library. They're both open-source community works, so if you're into this sort of thing, feel free to sign up for the mailing list and contribute too.

dogbreathcanadawrote inphp: ←Classes - Always Referencescyclotronwrote inphp: →Multidimensional Arrays