src/Alg/Math/Extrapolation.php
static public function calculateRanges( $values, $size, $precision = NULL )
	{
		Deprecation::getInstance()
			->setErrorVersion( '0.8.5' )
			->setExceptionVersion( '0.9' )
			->message( sprintf(
				'Please use %s (%s) instead',
				'public library "CeusMedia/Math"',
			 	'https://packagist.org/packages/ceus-media/math'
			) );
		$total		= array_sum( $values );
		$carry		= 0;
		$current	= 0;
		$ranges		= array();
		$power		= pow( 10, (int) $precision );
		foreach( $values as $value )
		{
			$ratio	= $value / $total;
			$x		= $ratio * $size * $power;
			$x_		= floor( $x ) / $power;
			$carry	+= $x - $x_;
			if( $carry >= 1)
			{
				$x_++;
				$carry--;
			}
			$ranges[]	= (object) array(
				'offset'	=> $current,
				'size'		=> $x_,
				'value'		=> $value,
				'ratio'		=> $ratio,
			);
			$current	+= $x_;
		}
		return $ranges;
	}
static public function calculateRanges( $values, $size, $precision = NULL )
	{
		Deprecation::getInstance()
			->setErrorVersion( '0.8.5' )
			->setExceptionVersion( '0.9' )
			->message( sprintf(
				'Please use %s (%s) instead',
				'public library "CeusMedia/Math"',
			 	'https://packagist.org/packages/ceus-media/math'
			) );
		$total		= array_sum( $values );
		$carry		= 0;
		$current	= 0;
		$ranges		= array();
		$power		= pow( 10, (int) $precision );
		foreach( $values as $value )
		{
			$ratio	= $value / $total;
			$x		= $ratio * $size * $power;
			$x_		= floor( $x ) / $power;
			$carry	+= $x - $x_;
			if( $carry >= 1)
			{
				$x_++;
				$carry--;
			}
			$ranges[]	= (object) array(
				'offset'	=> $current,
				'size'		=> $x_,
				'value'		=> $value,
				'ratio'		=> $ratio,
			);
			$current	+= $x_;
		}
		return $ranges;
	}
static public function calculateRanges ( $ values , $ size , $ precision = NULL ) { Deprecation :: getInstance ( ) -> setErrorVersion ( '0.8.5' ) -> setExceptionVersion ( '0.9' ) -> message ( sprintf ( 'Please use %s (%s) instead' , 'public library "CeusMedia/Math"' , 'https://packagist.org/packages/ceus-media/math' ) ) ; $ total = array_sum ( $ values ) ; $ carry = 0 ; $ current = 0 ; $ ranges = array ( ) ; $ power = pow ( 10 , ( int ) $ precision ) ; foreach ( $ values as $ value ) { $ ratio = $ value / $ total ; $ x = $ ratio * $ size * $ power ; $ x_ = floor ( $ x ) / $ power ; $ carry += $ x - $ x_ ; if ( $ carry >= 1 ) { $ x_ ++ ; $ carry -- ; } $ ranges [ ] = ( object ) array ( 'offset' => $ current , 'size' => $ x_ , 'value' => $ value , 'ratio' => $ ratio , ) ; $ current += $ x_ ; } return $ ranges ; }
Projects values into a sized container and returns list of range objects.
@access		public
@static
@param		array		$values		List of values
@param		float		$size		Size of container to project values to
@return		array		List of range objects
Projects values into a sized container and returns list of range objects .