public function portfolioStdDeviation() { $portfolio = new table_Portfolio(); $w = $portfolio->weights(); $n = 0; foreach ($w as $i) { $weights[$n] = $i; $n++; } $rets = $this->ReturnsArray(); $j = 0; foreach ($rets as $r) { $returns[$j] = $r; $j++; } $matrix = new Finance_Matrix($weights, $rets); $variance = $matrix->variancePortfolio($weights, $returns); $portfolioStdDeviation = sqrt($variance); return $portfolioStdDeviation; }