All pastes #771578 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-13 01:47 UTC
rendered paste body
	function StdDev( $Property, $Periods, $Pointer = null )
	{
		$Slice = $this -> Slice( $Property, $Periods, $Pointer );
		$Mean = $this -> SMA( $Property, $Periods, $Pointer );
		
		$Differences = array();
		$DifferencesSQ = array();
		foreach( $Slice as $K => $Point )
		{
			$Diff = $Point - $Mean;
			$DiffSQ = $Diff * $Diff;
			
			$DifferencesSQ[] = $DiffSQ;
		}
		
		$Variance = array_sum( $DifferencesSQ ) / count( $DifferencesSQ );
		$StdDev = sqrt( $Variance );

		return $StdDev;
	}