Fix dockblocks and minor bugs

This commit is contained in:
Dennis Eichhorn 2016-12-22 21:16:05 +01:00
parent 746130671b
commit 777f084a39
86 changed files with 1279 additions and 291 deletions

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Algorithm\Knappsack; namespace phpOMS\Algorithm\Knappsack;
use phpOMS\Algorithm\AlgorithmType;
/** /**
* Knappsack algorithm implementations * Knappsack algorithm implementations

View File

@ -39,7 +39,7 @@ abstract class SettingsAbstract implements OptionsInterface
/** /**
* Cache manager (pool). * Cache manager (pool).
* *
* @var \phpOMS\DataStorage\Cache\Pool * @var \phpOMS\DataStorage\Cache\CachePool
* @since 1.0.0 * @since 1.0.0
*/ */
protected $cache = null; protected $cache = null;

View File

@ -1146,7 +1146,7 @@ class DataMapperAbstract implements DataMapperInterface
{ {
$query = new Builder(self::$db); $query = new Builder(self::$db);
$query->prefix(self::$db->getPrefix()) $query->prefix(self::$db->getPrefix())
->random(static::$primaryKey) ->random(static::$primaryField)
->from(static::$table) ->from(static::$table)
->limit($amount); ->limit($amount);

View File

@ -126,7 +126,7 @@ class L11nManager
public function loadLanguageFromFile(string $language, string $from, string $file) /* : void */ public function loadLanguageFromFile(string $language, string $from, string $file) /* : void */
{ {
$lang = []; $lang = [];
if (file_exists(file)) { if (file_exists($file)) {
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
$lang = include $file; $lang = include $file;
} }

View File

@ -143,8 +143,6 @@ class Localization
/** /**
* Constructor. * Constructor.
* *
* @param L11nManager $l11nManager Localization manager
*
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class AR class AR
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARCH class ARCH
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARFIMA class ARFIMA
{ {

View File

@ -1,13 +1,34 @@
<?php <?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
namespace phpOMS\Math\Finance\Forecasting; use phpOMS\Math\Statistic\Average;
class ARIMA class ARIMA
{ {
private $data = [];
private $order = 0;
public function __construct(array $data, int $order = 12) public function __construct(array $data, int $order = 12)
{ {
$this->data = $data;
$this->order = $order;
if ($order !== 12 && $order !== 4) { if ($order !== 12 && $order !== 4) {
throw new \Exceptions('ARIMA only supports quarterly and monthly decomposition'); throw new \Exception('ARIMA only supports quarterly and monthly decomposition');
} }
} }
@ -67,7 +88,7 @@ class ARIMA
private function removeOutliers(array $data, float $deviation = 0.5) : array private function removeOutliers(array $data, float $deviation = 0.5) : array
{ {
$avg = AVerage::arithmeticMean($data); $avg = Average::arithmeticMean($data);
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
if ($value / $avg - 1 > $deviation) { if ($value / $avg - 1 > $deviation) {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ARMA class ARMA
{ {

View File

@ -1,19 +1,96 @@
<?php <?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting; namespace phpOMS\Math\Finance\Forecasting;
use phpOMS\Math\Statistic\Average; use phpOMS\Math\Statistic\Average;
/**
* Classical decomposition class.
*
* This can be used to simplify time series patterns for forecasts.
*
* @category Framework
* @package phpOMS\Math\Finance\Forecasting
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @see https://www.otexts.org/fpp/6/1
* @since 1.0.0
*/
class ClassicalDecomposition class ClassicalDecomposition
{ {
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
/* public */ const ADDITIVE = 0; /* public */ const ADDITIVE = 0;
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
/* public */ const MULTIPLICATIVE = 1; /* public */ const MULTIPLICATIVE = 1;
/**
* Decomposition mode.
*
* @var int
* @since 1.0.0
*/
private $mode = self::ADDITIVE; private $mode = self::ADDITIVE;
/**
* Raw data.
*
* @var array
* @since 1.0.0
*/
private $data = []; private $data = [];
/**
* Order or seasonal period.
*
* @var int
* @since 1.0.0
*/
private $order = 0; private $order = 0;
/**
* Raw data size.
*
* @var int
* @since 1.0.0
*/
private $dataSize = 0; private $dataSize = 0;
/**
* Constructor.
*
* @param array $data Historic data
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
* @param int $mode Decomposition mode
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(array $data, int $order, int $mode = self::ADDITIVE) public function __construct(array $data, int $order, int $mode = self::ADDITIVE)
{ {
$this->mode = $mode; $this->mode = $mode;
@ -23,12 +100,20 @@ class ClassicalDecomposition
$this->dataSize = count($data); $this->dataSize = count($data);
} }
/**
* Get decomposition.
*
* @return array Returns an array containing the trend cycle component, detrended series, seasonal component and remainder component.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDecomposition() : array public function getDecomposition() : array
{ {
$trendCycleComponent = self::computeTrendCycle($this->data, $this->order); $trendCycleComponent = self::computeTrendCycle($this->data, $this->order);
$detrendedSeries = self::computeDetrendedSeries($this->data, $trendCycleComponent, $this->mode); $detrendedSeries = self::computeDetrendedSeries($this->data, $trendCycleComponent, $this->mode);
$seasonalComponent = $this->computeSeasonalComponent($detrendedSeries, $this->order); $seasonalComponent = $this->computeSeasonalComponent($detrendedSeries, $this->order);
$remainderComponent = $this->computeRemainderComponent($trendCycleComponent, $seasonalComponent); $remainderComponent = self::computeRemainderComponent($this->data, $trendCycleComponent, $seasonalComponent, $this->mode);
return [ return [
'trendCycleComponent' => $trendCycleComponent, 'trendCycleComponent' => $trendCycleComponent,
@ -38,13 +123,36 @@ class ClassicalDecomposition
]; ];
} }
/**
* Calculate trend cycle
*
* @param array $data Data to analyze
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
*
* @return array Total moving average 2 x m-MA
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeTrendCycle(array $data, int $order) : array public static function computeTrendCycle(array $data, int $order) : array
{ {
$mMA = Average::totalMovingAverage($data, $order, null, true); $mMA = Average::totalMovingAverage($data, $order, null, true);
return $order % 2 === 0 ? Average::totalMovingAverage($mMA, 2, null, true) : $mMA; return $order % 2 === 0 ? Average::totalMovingAverage($mMA, $order, null, true) : $mMA;
} }
/**
* Calculate detrended series
*
* @param array $data Data to analyze
* @param array $trendCycleComponent Trend cycle component
* @param int $mode Detrend mode
*
* @return array Detrended series / seasonal normalized data
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeDetrendedSeries(array $data, array $trendCycleComponent, int $mode) : array public static function computeDetrendedSeries(array $data, array $trendCycleComponent, int $mode) : array
{ {
$detrended = []; $detrended = [];
@ -59,23 +167,46 @@ class ClassicalDecomposition
} }
/** /**
* Moving average can't start at index 0 since it needs to go m indices back for average -> can only start at m * Calculate the data start point for the decomposition
*
* By using averaging methods some initial data get's incorporated into the average which reduces the data points.
*
* @param int $dataSize Original data size
* @param int $trendCycleComponents Trend cycle component size
*
* @return int New data start index
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function getStartOfDecomposition(int $dataSize, int $trendCycleComponents) : int public static function getStartOfDecomposition(int $dataSize, int $trendCycleComponents) : int
{ {
return ($dataSize - $trendCycleComponents) / 2; return ($dataSize - $trendCycleComponents) / 2;
} }
private function computeSeasonalComponent() : array /**
* Calculate the seasonal component
*
* Average of the detrended values for every month, quarter, day etc.
*
* @param array $detrendedSeries Detrended series
* @param int $order Seasonal period (e.g. 4 = quarterly, 12 = monthly, 7 = weekly pattern in daily data)
*
* @return array
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private function computeSeasonalComponent(array $detrendedSeries, int $order) : array
{ {
$seasonalComponent = []; $seasonalComponent = [];
$count = count($this->data); $count = count($detrendedSeries);
for ($i = 0; $i < $this->dataSize; $i++) { for ($i = 0; $i < $order; $i++) {
$temp = []; $temp = [];
for ($j = $i * $this->order; $j < $count; $j += $this->order) { for ($j = $i; $j < $count; $j += $order) {
$temp[] = $this->data[$j]; $temp[] = $detrendedSeries[$j];
} }
$seasonalComponent[] = Average::arithmeticMean($temp); $seasonalComponent[] = Average::arithmeticMean($temp);
@ -84,15 +215,29 @@ class ClassicalDecomposition
return $seasonalComponent; return $seasonalComponent;
} }
public static function computeRemainderComponent(array $trendCycleComponent, array $seasonalComponent) : array /**
* Calculate the remainder component or error
*
* @param array $data Raw data
* @param array $trendCycleComponent Trend cycle component
* @param array $seasonalComponent Seasonal component
* @param int $mode Detrend mode
*
* @return array All remainders or absolute errors
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function computeRemainderComponent(array $data, array $trendCycleComponent, array $seasonalComponent, int $mode = self::ADDITIVE) : array
{ {
$dataSize = count($data);
$remainderComponent = []; $remainderComponent = [];
$count = count($trendCycleComponent); $count = count($trendCycleComponent);
$start = self::getStartOfDecomposition($this->dataSize, $count); $start = self::getStartOfDecomposition($dataSize, $count);
$seasons = count($seasonalComponent); $seasons = count($seasonalComponent);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
$remainderComponent[] = $this->mode === self::ADDITIVE ? $this->data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $this->data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]); $remainderComponent[] = $mode === self::ADDITIVE ? $data[$start + $i] - $trendCycleComponent[$i] - $seasonalComponent[$i % $seasons] : $data[$start + $i] / ($trendCycleComponent[$i] * $seasonalComponent[$i % $seasons]);
} }
return $remainderComponent; return $remainderComponent;

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class ExponentialSmoothing class ExponentialSmoothing
{ {

View File

@ -1,8 +1,22 @@
<?php <?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
namespace phpOMS\Math\Finance\Forecasting; use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\Forecast\Error;
use phpOMS\Math\Finance\Forecasting\SmoothingType;
class Brown class Brown
{ {
@ -22,7 +36,7 @@ class Brown
public function __construct(array $data, int $cycle = 0) public function __construct(array $data, int $cycle = 0)
{ {
$this->data = $data; $this->data = $data;
$this->cycle = $cycle; $this->cycle = $cycle;
} }
@ -33,7 +47,7 @@ class Brown
public function getRMSE() : float public function getRMSE() : float
{ {
return $this->getRMSE; return $this->rmse;
} }
public function getMSE() : float public function getMSE() : float
@ -58,13 +72,13 @@ class Brown
public function getForecast(int $future = 1, int $smoothing = SmoothingType::CENTERED_MOVING_AVERAGE) : array public function getForecast(int $future = 1, int $smoothing = SmoothingType::CENTERED_MOVING_AVERAGE) : array
{ {
$trendCycle = $this->getTrendCycle($this->$cycle); $trendCycle = $this->getTrendCycle($this->cycle);
$seasonality = $this->getSeasonality($trendCycle); $seasonality = $this->getSeasonality($trendCycle);
$seasonalityIndexMap = $this->generateSeasonalityMap($this->cycle, $seasonality); $seasonalityIndexMap = $this->generateSeasonalityMap($this->cycle, $seasonality);
$adjustedSeasonalityIndexMap = $this->generateAdjustedSeasonalityMap($this->cycle, $seasonalityIndexMap); $adjustedSeasonalityIndexMap = $this->generateAdjustedSeasonalityMap($this->cycle, $seasonalityIndexMap);
$seasonalIndex = $this->getSeasonalIndex($this->cycle, $adjustedSeasonalityIndexMap); $seasonalIndex = $this->getSeasonalIndex($this->cycle, $adjustedSeasonalityIndexMap);
$adjustedData = $this->getAdjustedData($this->cycle, $seasonalIndex); $adjustedData = $this->getAdjustedData($this->cycle, $seasonalIndex);
$optimizedForecast = $this->getOptimizedForecast($future, $adjustedData); $optimizedForecast = $this->getOptimizedForecast($future, $adjustedData);
return $this->getReseasonalized($optimizedForecast, $seasonalIndex); return $this->getReseasonalized($optimizedForecast, $seasonalIndex);
} }
@ -74,8 +88,8 @@ class Brown
$centeredMovingAverage = []; $centeredMovingAverage = [];
$length = count($this->data); $length = count($this->data);
for($i = $cycle; $i < $length - $cycle; $i++) { for ($i = $cycle; $i < $length - $cycle; $i++) {
$centeredMovingAverage[$i] = Average::arithmetic(array_slice($this->data, $i - $cycle, $cycle)); $centeredMovingAverage[$i] = Average::arithmeticMean(array_slice($this->data, $i - $cycle, $cycle));
} }
return $centeredMovingAverage; return $centeredMovingAverage;
@ -84,21 +98,21 @@ class Brown
private function getSeasonality(array $trendCycle) : array private function getSeasonality(array $trendCycle) : array
{ {
$seasonality = []; $seasonality = [];
foreach($trendCycle as $key => $value) { foreach ($trendCycle as $key => $value) {
$seasonality[$key] = $this->data[$key]/$value; $seasonality[$key] = $this->data[$key] / $value;
} }
return $seasonality; return $seasonality;
} }
private function generateSeasonality(int $cycle, array $seasonality) : array private function generateSeasonalityMap(int $cycle, array $seasonality) : array
{ {
$map = []; $map = [];
foreach($seasonality as $key => $value) { foreach ($seasonality as $key => $value) {
$map[$key % $cycle][] = $value; $map[$key % $cycle][] = $value;
} }
foreach($map as $key => $value) { foreach ($map as $key => $value) {
$map[$key] = Average::arithmeticMean($value); $map[$key] = Average::arithmeticMean($value);
} }
@ -109,7 +123,7 @@ class Brown
{ {
$total = array_sum($seasonality); $total = array_sum($seasonality);
foreach($seasonality as $key => $value) { foreach ($seasonality as $key => $value) {
$seasonality[$key] = $cycle * $value / $total; $seasonality[$key] = $cycle * $value / $total;
} }
@ -120,7 +134,7 @@ class Brown
{ {
$index = []; $index = [];
foreach($this->data as $key => $value) { foreach ($this->data as $key => $value) {
$index[$key] = $seasonalityMap[$key % $cycle]; $index[$key] = $seasonalityMap[$key % $cycle];
} }
@ -131,7 +145,7 @@ class Brown
{ {
$adjusted = []; $adjusted = [];
foreach($this->data as $key => $value) { foreach ($this->data as $key => $value) {
$adjusted[$key] = $this->data[$key] / $seasonalIndex[$key]; $adjusted[$key] = $this->data[$key] / $seasonalIndex[$key];
} }
@ -141,7 +155,7 @@ class Brown
private function forecast(int $future, float $alpha, array $data, array &$error) : array private function forecast(int $future, float $alpha, array $data, array &$error) : array
{ {
$forecast = []; $forecast = [];
$length = count($data) + $future; $length = count($data) + $future;
$forecast[0] = $data[0]; $forecast[0] = $data[0];
$forecast[1] = $data[1]; $forecast[1] = $data[1];
@ -149,9 +163,9 @@ class Brown
$error[0] = 0; $error[0] = 0;
$error[1] = $data[1] - $forecast[1]; $error[1] = $data[1] - $forecast[1];
for($i = 2; $i < $length; $i++) { for ($i = 2; $i < $length; $i++) {
$forecast[$i] = 2 * $data[$i-1] - $data[$i - 2] - 2 * (1 - $alpha) * $error[$i-1] + pow(1-$alpah, 2) * $error[$i - 2]; $forecast[$i] = 2 * $data[$i - 1] - $data[$i - 2] - 2 * (1 - $alpha) * $error[$i - 1] + pow(1 - $alpha, 2) * $error[$i - 2];
$error[$i] = $data[$i] - $forecast[$i]; $error[$i] = $data[$i] - $forecast[$i];
} }
return $forecast; return $forecast;
@ -159,27 +173,27 @@ class Brown
private function getOptimizedForecast(int $future, array $adjustedData) : array private function getOptimizedForecast(int $future, array $adjustedData) : array
{ {
$rmse = 0; $this->rmse = 0;
$alpha = 0.00; $alpha = 0.00;
$forecast = []; $forecast = [];
$error = [];
while($alpha < 1) { while ($alpha < 1) {
$error = [];
$tempForecast = $this->forecast($future, $alpha, $adjustedData, $error); $tempForecast = $this->forecast($future, $alpha, $adjustedData, $error);
$alpha += 0.01; $alpha += 0.01;
$tempRMSE = Error::getRootMeanSquaredError($error); $tempRMSE = Error::getRootMeanSquaredError($error);
if($tempRMSE < $this->rmse) { if ($tempRMSE < $this->rmse) {
$this->rmse = $tempRMSE; $this->rmse = $tempRMSE;
$forecast = $tempForecast; $forecast = $tempForecast;
} }
} }
$this->errors = $error; $this->errors = $error;
$this->mse = Error::getMeanSquaredError($error); $this->mse = Error::getMeanSquaredError($error);
$this->mae = Error::getMeanAbsoluteError($error); $this->mae = Error::getMeanAbsoulteError($error);
$this->sse = Error::getSumSquaredError($error); $this->sse = Error::getSumSquaredError($error);
return $forecast; return $forecast;
} }
@ -188,7 +202,7 @@ class Brown
{ {
$reSeasonalized = []; $reSeasonalized = [];
foreach($forecast as $key => $value) { foreach ($forecast as $key => $value) {
$reSeasonalized[$key] = $value * $seasonalIndex[$key]; $reSeasonalized[$key] = $value * $seasonalIndex[$key];
} }

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class GARCH class GARCH
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class MA class MA
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class NAR class NAR
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class NMA class NMA
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Finance\Forecasting; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Finance\Forecasting;
class SARIMA class SARIMA
{ {

View File

@ -231,7 +231,7 @@ class Functions
* *
* @param int $a Value to test * @param int $a Value to test
* *
* @return int * @return bool
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
@ -250,7 +250,7 @@ class Functions
* *
* @param int $a Value to test * @param int $a Value to test
* *
* @return int * @return bool
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
@ -270,7 +270,9 @@ class Functions
* @example The relative fiscal month (August) in a company where the fiscal year starts in July. * @example The relative fiscal month (August) in a company where the fiscal year starts in July.
* @example 2 = getRelativeDegree(8, 12, 7); * @example 2 = getRelativeDegree(8, 12, 7);
* *
* @param int $a Value to test * @param mixed $value Value to get degree
* @param mixed $length Circle size
* @param mixed $start Start value
* *
* @return int * @return int
* *

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Graph; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
class Dijkstra class Dijkstra
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Graph; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Graph;
class FloydWarshall class FloydWarshall
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Backpack class Backpack
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class BruteForce class BruteForce
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class GA class GA
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Item class Item
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class ItemPool class ItemPool
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\Knappsack; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\Knappsack;
class Population class Population
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class BruteForce class BruteForce
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class GA class GA
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Population class Population
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Workday class Workday
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class Worker class Worker
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Optimization\ShiftScheduling; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Optimization\ShiftScheduling;
class WorkerPool class WorkerPool
{ {

View File

@ -28,6 +28,13 @@ namespace phpOMS\Math\Shape\D2;
*/ */
class Polygon implements D2ShapeInterface class Polygon implements D2ShapeInterface
{ {
/**
* Epsilon for float comparison.
*
* @var float
* @since 1.0.0
*/
/* public */ const EPSILON = 0.00001;
/** /**
* Coordinates. * Coordinates.
@ -123,28 +130,44 @@ class Polygon implements D2ShapeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function pointInPolygon(array $point) : int public function pointInPolygon(array $point) : int
{ {
$length = count($this->coord); return self::isPointInPolygon($point, $this->coord);
}
/**
* Point polygon relative position
*
* @param array $point Point location
* @param array $polygon Polygon definition
*
* @return int
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function isPointInPolygon(array $point, array $polygon) : int
{
$length = count($polygon);
// Polygon has to start and end with same point // Polygon has to start and end with same point
if ($this->coord[0]['x'] !== $this->coord[$length - 1]['x'] || $this->coord[0]['y'] !== $this->coord[$length - 1]['y']) { if ($polygon[0]['x'] !== $polygon[$length - 1]['x'] || $polygon[0]['y'] !== $polygon[$length - 1]['y']) {
$this->coord[] = $this->coord[0]; $polygon[] = $polygon[0];
} }
// On vertex? // On vertex?
if (self::isOnVertex($point, $this->coord)) { if (self::isOnVertex($point, $polygon)) {
return 0; return 0;
} }
// Inside or ontop? // Inside or ontop?
$countIntersect = 0; $countIntersect = 0;
$this->coord_count = count($this->coord); $polygon_count = count($polygon);
// todo: return based on highest possibility not by first match // todo: return based on highest possibility not by first match
for ($i = 1; $i < $this->coord_count; $i++) { for ($i = 1; $i < $polygon_count; $i++) {
$vertex1 = $this->coord[$i - 1]; $vertex1 = $polygon[$i - 1];
$vertex2 = $this->coord[$i]; $vertex2 = $polygon[$i];
if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON && abs($vertex1['y'] - $point['y']) < self::EPSILON && $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] < max($vertex1['x'], $vertex2['x'])) { if (abs($vertex1['y'] - $vertex2['y']) < self::EPSILON && abs($vertex1['y'] - $point['y']) < self::EPSILON && $point['x'] > min($vertex1['x'], $vertex2['x']) && $point['x'] < max($vertex1['x'], $vertex2['x'])) {
return 0; // boundary return 0; // boundary
@ -180,9 +203,25 @@ class Polygon implements D2ShapeInterface
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
private static function isOnVertex(array $point) : bool public function onVertex(array $point) : bool
{ {
foreach ($this->coord as $vertex) { return self::isOnVertex($point, $this->coord);
}
/**
* Is point on vertex?
*
* @param array $point Point location
* @param array $polygon Polygon definition
*
* @return bool
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private static function isOnVertex(array $point, array $polygon) : bool
{
foreach ($polygon as $vertex) {
if (abs($point['x'] - $vertex['x']) < self::EPSILON && abs($point['y'] - $vertex['y']) < self::EPSILON) { if (abs($point['x'] - $vertex['x']) < self::EPSILON && abs($point['y'] - $vertex['y']) < self::EPSILON) {
return true; return true;
} }

View File

@ -1,5 +1,19 @@
<?php <?php
namespace phpOMS\Math\Shape\D2; /**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Shape\D2;
class Quadrilateral implements D2ShapeInterface class Quadrilateral implements D2ShapeInterface
{ {

View File

@ -1,5 +1,19 @@
<?php <?php
namespace phpOMS\Math\Shape\D3; /**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Shape\D3;
class Prism implements D3ShapeInterface class Prism implements D3ShapeInterface
{ {

View File

@ -19,7 +19,7 @@ namespace phpOMS\Math\Shape\D3;
* Sphere shape. * Sphere shape.
* *
* @category Framework * @category Framework
* @package phpOMS\DataStorage\Database * @package phpOMS\Math\Shape
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -28,7 +28,22 @@ namespace phpOMS\Math\Shape\D3;
*/ */
class Sphere implements D3ShapeInterface class Sphere implements D3ShapeInterface
{ {
/**
* Radius.
*
* @var float
* @since 1.0.0
*/
private $radius = 0.0;
/**
* Constructor.
*
* @param float $radius Sphere radius
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function __construct(float $radius) public function __construct(float $radius)
{ {
$this->radius = $radius; $this->radius = $radius;
@ -68,11 +83,31 @@ class Sphere implements D3ShapeInterface
return $angle * $radius; return $angle * $radius;
} }
/**
* Create sphere by radius
*
* @param float $r Radius
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function byRadius(float $r) : Sphere public static function byRadius(float $r) : Sphere
{ {
return new self($r); return new self($r);
} }
/**
* Create sphere by volume
*
* @param float $v Sphere volume
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function byVolume(float $v) : Sphere public static function byVolume(float $v) : Sphere
{ {
return new self(self::getRadiusByVolume($v)); return new self(self::getRadiusByVolume($v));
@ -81,25 +116,35 @@ class Sphere implements D3ShapeInterface
/** /**
* Radius * Radius
* *
* @param float $V Volume * @param float $v Volume
* *
* @return float * @return float
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function getRadiusByVolume(float $V) : float public static function getRadiusByVolume(float $v) : float
{ {
return pow($V * 3 / (4 * pi()), 1 / 3); return pow($v * 3 / (4 * pi()), 1 / 3);
} }
/**
* Create sphere by surface
*
* @param float $s Sphere surface
*
* @return Sphere
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function bySurface(float $s) : Sphere public static function bySurface(float $s) : Sphere
{ {
return new self(self::getRadiusBySurface($s)); return new self(self::getRadiusBySurface($s));
} }
/** /**
* Radius * Get radius by sphere
* *
* @param float $S Surface * @param float $S Surface
* *
@ -113,13 +158,21 @@ class Sphere implements D3ShapeInterface
return sqrt($S / (4 * pi())); return sqrt($S / (4 * pi()));
} }
/**
* Get volume
*
* @return float Sphere volume
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getVolume() : float public function getVolume() : float
{ {
return self::getVolumeByRadius($this->radius); return self::getVolumeByRadius($this->radius);
} }
/** /**
* Volume * Get sphere volume by radius
* *
* @param float $r Radius * @param float $r Radius
* *
@ -133,11 +186,27 @@ class Sphere implements D3ShapeInterface
return 4 / 3 * pi() * $r ** 3; return 4 / 3 * pi() * $r ** 3;
} }
/**
* Get radius
*
* @return float Sphere radius
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getRadius() : float public function getRadius() : float
{ {
return $this->radius; return $this->radius;
} }
/**
* Get surface
*
* @return float Sphere surface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getSurface() : float public function getSurface() : float
{ {
return self::getSurfaceByRadius($this->radius); return self::getSurfaceByRadius($this->radius);

View File

@ -20,7 +20,7 @@ namespace phpOMS\Math\Statistic;
* Average class. * Average class.
* *
* @category Framework * @category Framework
* @package phpOMS\DataStorage\Database * @package phpOMS\Math\Statistic
* @author OMS Development Team <dev@oms.com> * @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0 * @license OMS License 1.0
@ -61,9 +61,19 @@ class Average
} }
/** /**
* t = 3 and p = 3 means -1 0 +1, t = 4 and p = 2 means -1 0 * Moving average of dataset
* periods should be replaced with order than it's possible to test for even or odd m *
* todo: maybe floor()? * @param array $x Dataset
* @param int $order Periods to use for average
* @param array $weight Weight for moving average
* @param bool $symmetric Cyclic moving average
*
* @return array Moving average of data
*
* @throws \Exception
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array public static function totalMovingAverage(array $x, int $order, array $weight = null, bool $symmetric = false) : array
{ {
@ -79,15 +89,15 @@ class Average
} }
/** /**
* Moving average or order m. * Moving average of element in dataset
* *
* @param array $x Dataset * @param array $x Dataset
* @param int $t Current period * @param int $t Current period
* @param int $periods Periods to use for average * @param int $order Periods to use for average
* @param array $weight Weight for moving average
* @param bool $symmetric Cyclic moving average
* *
* @return float * @return float Moving average
*
* @todo : allow counter i also to go into the future... required for forecast how? should be doable!
* *
* @throws \Exception * @throws \Exception
* *
@ -107,7 +117,7 @@ class Average
$end = $order % 2 === 0 ? $end - 1 : $end; $end = $order % 2 === 0 ? $end - 1 : $end;
$start = $t - 1 - ($periods - 2); $start = $t - 1 - ($periods - 2);
if (isset($weight)) { if (!empty($weight)) {
return self::weightedAverage(array_slice($x, $start, $end - $start), array_slice($weight, $start, $end - $start)); return self::weightedAverage(array_slice($x, $start, $end - $start), array_slice($weight, $start, $end - $start));
} else { } else {
return self::arithmeticMean(array_slice($x, $start, $end - $start)); return self::arithmeticMean(array_slice($x, $start, $end - $start));

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Statistic\Forecast; namespace phpOMS\Math\Statistic\Forecast;
use phpOMS\Math\Functions; use phpOMS\Math\Functions\Functions;
use phpOMS\Math\Statistic\Average; use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\MeasureOfDispersion; use phpOMS\Math\Statistic\MeasureOfDispersion;
@ -124,6 +124,21 @@ class Error
return Average::arithmeticMean(Functions::abs($errors)); return Average::arithmeticMean(Functions::abs($errors));
} }
/**
* Get mean squared error (MSE).
*
* @param array $errors Errors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getMeanSquaredError(array $errors) : float
{
return Average::arithmeticMean(self::square($errors));
}
/** /**
* Get root mean squared error (RMSE). * Get root mean squared error (RMSE).
* *
@ -136,7 +151,6 @@ class Error
*/ */
public static function getRootMeanSquaredError(array $errors) : float public static function getRootMeanSquaredError(array $errors) : float
{ {
// sqrt(Average::getVariance($error)+pow(Average::arithmeticMean($error), 2));
return sqrt(Average::arithmeticMean(self::square($errors))); return sqrt(Average::arithmeticMean(self::square($errors)));
} }
@ -195,6 +209,18 @@ class Error
return $error; return $error;
} }
/**
* Get R Bar Squared
*
* @param float $R R
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function getRBarSquared(float $R, int $observations, int $predictors) : float public static function getRBarSquared(float $R, int $observations, int $predictors) : float
{ {
return 1 - (1 - $R * ($observations - 1) / ($observations - $predictors - 1)); return 1 - (1 - $R * ($observations - 1) / ($observations - $predictors - 1));
@ -203,6 +229,14 @@ class Error
/** /**
* Get Aike's information criterion (AIC) * Get Aike's information criterion (AIC)
* *
* @param float $sse SSE
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function getAkaikeInformationCriterion(float $sse, int $observations, int $predictors) : float public static function getAkaikeInformationCriterion(float $sse, int $observations, int $predictors) : float
{ {
@ -213,6 +247,15 @@ class Error
* Get corrected Aike's information criterion (AIC) * Get corrected Aike's information criterion (AIC)
* *
* Correction for small amount of observations * Correction for small amount of observations
*
* @param float $aic AIC
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function getCorrectedAkaikeInformationCriterion(float $aic, int $observations, int $predictors) : float public static function getCorrectedAkaikeInformationCriterion(float $aic, int $observations, int $predictors) : float
{ {
@ -222,6 +265,14 @@ class Error
/** /**
* Get Bayesian information criterion (BIC) * Get Bayesian information criterion (BIC)
* *
* @param float $sse SSE
* @param int $observations Amount of observations
* @param int $predictors Amount of predictors
*
* @return float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function getSchwarzBayesianInformationCriterion(float $sse, int $observations, int $predictors) : float public static function getSchwarzBayesianInformationCriterion(float $sse, int $observations, int $predictors) : float
{ {

View File

@ -18,7 +18,7 @@ namespace phpOMS\Math\Statistic\Forecast;
use phpOMS\Datatypes\Enum; use phpOMS\Datatypes\Enum;
/** /**
* Address type enum. * Prediction interval multiplier.
* *
* @category Framework * @category Framework
* @package phpOMS\Datatypes * @package phpOMS\Datatypes

View File

@ -29,10 +29,11 @@ namespace phpOMS\Math\Statistic\Forecast;
class Forecasts class Forecasts
{ {
/** /**
* Get forecast interval. * Get forecast/prediction interval.
* *
* @param array $observed Dataset * @param float $forecast Forecast value
* @param array $forecasted Forecasted * @param float $standardDeviation Standard Deviation of forecast
* @param float $interval Forecast multiplier for prediction intervals
* *
* @return array * @return array
* *

View File

@ -39,7 +39,7 @@ class LevelLogRegression extends RegressionAbstract
} }
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$x[$i] = log($x[i]); $x[$i] = log($x[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -39,7 +39,7 @@ class LogLevelRegression extends RegressionAbstract
} }
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$y[$i] = log($y[i]); $y[$i] = log($y[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -39,8 +39,8 @@ class LogLogRegression extends RegressionAbstract
} }
for ($i = 0; $i < $c; $i++) { for ($i = 0; $i < $c; $i++) {
$x[$i] = log($x[i]); $x[$i] = log($x[$i]);
$y[$i] = log($y[i]); $y[$i] = log($y[$i]);
} }
return parent::getRegression($x, $y); return parent::getRegression($x, $y);

View File

@ -1,6 +1,21 @@
<?php <?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Statistic\Forecast\Regression;
namespace phpOMS\Math\Statistic\Forecast\Regression; use phpOMS\Math\Matrix\Matrix;
class MultipleLinearRegression class MultipleLinearRegression
{ {
@ -10,14 +25,14 @@ class MultipleLinearRegression
public static function getRegression(array $x, array $y) : array public static function getRegression(array $x, array $y) : array
{ {
$X = new Matrix(count($x), count($x[0])); $X = new Matrix(count($x), count($x[0]));
$X->setArray($x); $X->setMatrix($x);
$XT = $X->transpose(); $XT = $X->transpose();
$Y = new Matrix(count($y)); $Y = new Matrix(count($y));
$Y->setArray($y); $Y->setMatrix($y);
return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->toArray(); return $XT->mult($X)->inverse()->mult($XT)->mult($Y)->getMatrix();
} }
public static function getVariance() : float public static function getVariance() : float

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Statistic\Forecast\Regression; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Statistic\Forecast\Regression;
use phpOMS\Math\Statistic\Average; use phpOMS\Math\Statistic\Average;
use phpOMS\Math\Statistic\Forecast\ForecastIntervalMultiplier; use phpOMS\Math\Statistic\Forecast\ForecastIntervalMultiplier;
@ -18,6 +31,8 @@ abstract class RegressionAbstract
* *
* @return array [b0 => ?, b1 => ?] * @return array [b0 => ?, b1 => ?]
* *
* @throws \Exception
*
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class BetaDistribution class BetaDistribution
{ {

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution; namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions; use phpOMS\Math\Functions\Functions;
/** /**
* Binomial distribution. * Binomial distribution.

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution; namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions; use phpOMS\Math\Functions\Functions;
/** /**
* Chi squared distribution. * Chi squared distribution.

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class FDistribution class FDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class GammaDistribution class GammaDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class HypergeometricDistribution class HypergeometricDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogDistribution class LogDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogNormalDistribution class LogNormalDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class LogisticDistribution class LogisticDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class ParetoDistribution class ParetoDistribution
{ {

View File

@ -16,7 +16,7 @@
namespace phpOMS\Math\Stochastic\Distribution; namespace phpOMS\Math\Stochastic\Distribution;
use phpOMS\Math\Functions; use phpOMS\Math\Functions\Functions;
/** /**
* Well known functions class. * Well known functions class.

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class TDistribution class TDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Math\Stochastic\Distribution; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Math\Stochastic\Distribution;
class WeibullDistribution class WeibullDistribution
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Message\Mail; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class OAuth class OAuth
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Message\Mail; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class Pop3 class Pop3
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Message\Mail; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Mail;
class Smtp class Smtp
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Message\Socket; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Socket;
class Request class Request
{ {

View File

@ -1,6 +1,19 @@
<?php <?php
/**
namespace phpOMS\Message\Socket; * Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace phpOMS\Message\Socket;
class Response class Response
{ {

View File

@ -35,7 +35,7 @@ class ActivateAbstract
/** /**
* Deactivate module. * Deactivate module.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void
@ -68,7 +68,7 @@ class ActivateAbstract
/** /**
* Deactivate module in database. * Deactivate module in database.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -35,7 +35,7 @@ class DeactivateAbstract
/** /**
* Deactivate module. * Deactivate module.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void
@ -68,7 +68,7 @@ class DeactivateAbstract
/** /**
* Deactivate module in database. * Deactivate module in database.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -38,7 +38,7 @@ class InstallerAbstract
/** /**
* Register module in database. * Register module in database.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void
@ -91,7 +91,7 @@ class InstallerAbstract
* Install module. * Install module.
* *
* @param string $routePath Route Path * @param string $routePath Route Path
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void
@ -109,7 +109,7 @@ class InstallerAbstract
/** /**
* Activate after install. * Activate after install.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -34,7 +34,7 @@ class UninstallAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -34,7 +34,7 @@ class UpdateAbstract
/** /**
* Install module. * Install module.
* *
* @param Pool $dbPool Database instance * @param DatabasePool $dbPool Database instance
* @param InfoManager $info Module info * @param InfoManager $info Module info
* *
* @return void * @return void

View File

@ -271,7 +271,7 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab
/** /**
* Get collection that contains every n-th element. * Get collection that contains every n-th element.
* *
* @param $int $n Every n-th element * @param int $n Every n-th element
* *
* @return Collection * @return Collection
* *
@ -622,12 +622,16 @@ class Collection implements \Countable, \ArrayAccess, \Iterator, \JsonSerializab
/** /**
* Offset to retrieve * Offset to retrieve
* @link http://php.net/manual/en/arrayaccess.offsetget.php *
* @param mixed $offset <p> * @param mixed $offset The offset to retrieve.
* The offset to retrieve. *
* </p>
* @return mixed Can return all value types. * @return mixed Can return all value types.
* @since 5.0.0 *
* @throws \Exception
*
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
* @since 1.0.0
*/ */
public function offsetGet($offset) public function offsetGet($offset)
{ {

View File

@ -46,7 +46,7 @@ class BinaryTree extends Tree
/** /**
* Get left node of a node. * Get left node of a node.
* *
* @param Node $node Tree node * @param Node $base Tree node
* *
* @return Node Left node * @return Node Left node
* *
@ -64,7 +64,7 @@ class BinaryTree extends Tree
/** /**
* Get right node of a node. * Get right node of a node.
* *
* @param Node $node Tree node * @param Node $base Tree node
* *
* @return Node Right node * @return Node Right node
* *
@ -73,7 +73,7 @@ class BinaryTree extends Tree
*/ */
public function getRight(Node $base) public function getRight(Node $base)
{ {
$neighbors = $base->getNeighbors($base); $neighbors = $this->getNeighbors($base);
// todo: index can be wrong, see setLeft/setRight // todo: index can be wrong, see setLeft/setRight
return $neighbors[1] ?? null; return $neighbors[1] ?? null;
@ -93,7 +93,7 @@ class BinaryTree extends Tree
public function setLeft(Node $base, Node $left) : BinaryTree public function setLeft(Node $base, Node $left) : BinaryTree
{ {
if($this->getLeft($base) === null) { if($this->getLeft($base) === null) {
$this->addNode($base, $left); $this->addNodeRelative($base, $left);
// todo: doesn't know that this is left // todo: doesn't know that this is left
// todo: maybe need to add numerics to edges? // todo: maybe need to add numerics to edges?
} else { } else {
@ -117,7 +117,7 @@ class BinaryTree extends Tree
public function setRight(Node $base, Node $right) /* : void */ public function setRight(Node $base, Node $right) /* : void */
{ {
if($this->getRight($base) === null) { if($this->getRight($base) === null) {
$this->addNode($base, $right); $this->addNodeRelative($base, $right);
// todo: doesn't know that this is right // todo: doesn't know that this is right
// todo: maybe need to add numerics to edges? // todo: maybe need to add numerics to edges?
} else { } else {
@ -196,6 +196,8 @@ class BinaryTree extends Tree
* *
* @param Node $node1 Tree node1 * @param Node $node1 Tree node1
* @param Node $node2 Tree node2 (optional, can be different tree) * @param Node $node2 Tree node2 (optional, can be different tree)
*
* @return bool True if tree is symmetric, false if tree is not symmetric
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -54,30 +54,46 @@ class Graph
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function addNode(Node $node) : Graph public function addNode(Node $node) : Graph
{ {
$this->nodes[] = $node; $this->nodes[] = $node;
return $this; return $this;
} }
/** /**
* Set node in graph. * Add node to graph.
* *
* @param mixed $key Key of node * @param Node $relative Relative graph node
* @param Node $node Graph node * @param Node $node Graph node
* *
* @return Graph * @return Graph
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function setNode($key, Node $node) : Graph public function addNodeRelative(Node $relative, Node $node) : Graph
{ {
$this->nodes[$key] = $node; return $this;
}
return $this; /**
} * Set node in graph.
*
* @param mixed $key Key of node
* @param Node $node Graph node
*
* @return Graph
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setNode($key, Node $node) : Graph
{
$this->nodes[$key] = $node;
return $this;
}
/** /**
* Add edge to graph. * Add edge to graph.
@ -91,28 +107,28 @@ class Graph
*/ */
public function addEdge(Edge $edge) : Graph public function addEdge(Edge $edge) : Graph
{ {
$this->edges[] = $edge; $this->edges[] = $edge;
return $this; return $this;
} }
/** /**
* Set edge in graph. * Set edge in graph.
* *
* @param mixed $key Edge key * @param mixed $key Edge key
* @param Edge $edge Edge to set * @param Edge $edge Edge to set
* *
* @return Graph * @return Graph
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function setEdge($key, Edge $edge) /* : void */ public function setEdge($key, Edge $edge) /* : void */
{ {
$this->edges[$key] = $edge; $this->edges[$key] = $edge;
return $this; return $this;
} }
/** /**
* Get graph node * Get graph node
@ -125,9 +141,22 @@ class Graph
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getNode($key) : Node public function getNode($key) : Node
{ {
return $this->nodes[$key]; return $this->nodes[$key];
} }
/**
* Get graph nodes
*
* @return Node[]
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getNodes() : array
{
return $this->nodes;
}
/** /**
* Get graph edge. * Get graph edge.
@ -140,9 +169,9 @@ class Graph
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getEdge($key) : Edge public function getEdge($key) : Edge
{ {
return $this->edges[$key]; return $this->edges[$key];
} }
/** /**
* Get all edges of a node * Get all edges of a node
@ -156,15 +185,15 @@ class Graph
*/ */
public function getEdgesOfNode($node) : array public function getEdgesOfNode($node) : array
{ {
if(!($node instanceof Node)) { if (!($node instanceof Node)) {
$node = $this->getNode($node); $node = $this->getNode($node);
} }
$edges = []; $edges = [];
foreach($this->edges as $edge) { foreach ($this->edges as $edge) {
$nodes = $edge->getNodes(); $nodes = $edge->getNodes();
if($nodes[0] === $node || $nodes[1] === $node) { if ($nodes[0] === $node || $nodes[1] === $node) {
$edges[] = $edge; $edges[] = $edge;
} }
} }
@ -184,19 +213,19 @@ class Graph
*/ */
public function getNeighbors($node) : array public function getNeighbors($node) : array
{ {
if(!($node instanceof Node)) { if (!($node instanceof Node)) {
$node = $this->getNode($node); $node = $this->getNode($node);
} }
$edges = $this->getEdgesOfNode($node); $edges = $this->getEdgesOfNode($node);
$neighbors = []; $neighbors = [];
foreach($edges as $edge) { foreach ($edges as $edge) {
$nodes = $edge->getNodes(); $nodes = $edge->getNodes();
if($nodes[0] !== $node && $nodes[0] !== null) { if ($nodes[0] !== $node && $nodes[0] !== null) {
$neighbors[] = $nodes[0]; $neighbors[] = $nodes[0];
} elseif($nodes[1] !== $node && $nodes[0] !== null) { } elseif ($nodes[1] !== $node && $nodes[0] !== null) {
$neighbors[] = $nodes[1]; $neighbors[] = $nodes[1];
} }
} }
@ -398,9 +427,9 @@ class Graph
{ {
$diameter = 0; $diameter = 0;
foreach($this->nodes as $node1) { foreach ($this->nodes as $node1) {
foreach($this->nodes as $node2) { foreach ($this->nodes as $node2) {
if($node1 === $node2) { if ($node1 === $node2) {
continue; continue;
} }

View File

@ -231,7 +231,7 @@ class Tree extends Graph
} }
$callback($node); $callback($node);
$neighbors = $this->getNeighbors(); $neighbors = $this->getNeighbors($node);
foreach($neighbors as $neighbor) { foreach($neighbors as $neighbor) {
// todo: get neighbors needs to return in ordered way // todo: get neighbors needs to return in ordered way
@ -253,7 +253,7 @@ class Tree extends Graph
return; return;
} }
$neighbors = $this->getNeighbors(); $neighbors = $this->getNeighbors($node);
foreach($neighbors as $neighbor) { foreach($neighbors as $neighbor) {
// todo: get neighbors needs to return in ordered way // todo: get neighbors needs to return in ordered way

View File

@ -16,7 +16,7 @@
namespace phpOMS\Stdlib\Queue; namespace phpOMS\Stdlib\Queue;
/** /**
* Router class. * Priority queue class.
* *
* @category Framework * @category Framework
* @package phpOMS\Stdlib * @package phpOMS\Stdlib
@ -45,15 +45,13 @@ class PriorityQueue implements \Countable, \Serializable
*/ */
private $queue = []; private $queue = [];
private $mode = 0;
/** /**
* Constructor. * Constructor.
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function __construct($mode = '') public function __construct()
{ {
} }

View File

@ -397,6 +397,7 @@ class Directory extends FileAbstract implements DirectoryInterface
*/ */
public static function name(string $path) : string public static function name(string $path) : string
{ {
// todo: name doesn' t make sense
// TODO: Implement name() method. // TODO: Implement name() method.
} }

View File

@ -225,6 +225,21 @@ class File extends FileAbstract implements FileInterface
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function dirname(string $path) : string public static function dirname(string $path) : string
{
return basename(dirname($path));
}
/**
* Gets the directory path of a file.
*
* @param string $path Path of the file to get the directory name for.
*
* @return string Returns the directory name of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public static function dirpath(string $path) : string
{ {
return dirname($path); return dirname($path);
} }
@ -287,11 +302,27 @@ class File extends FileAbstract implements FileInterface
return true; return true;
} }
/**
* Gets the directory name of a file.
*
* @return string Returns the directory name of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDirName() : string public function getDirName() : string
{ {
return basename(dirname($this->path)); return basename(dirname($this->path));
} }
/**
* Gets the directory path of a file.
*
* @return string Returns the directory path of the file.
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getDirPath() : string public function getDirPath() : string
{ {
return dirname($this->path); return dirname($this->path);

View File

@ -227,10 +227,8 @@ class ArrayUtils
* *
* Useful for parsing command line parsing * Useful for parsing command line parsing
* *
* @param array $data Data to convert * @param string $id Id to find
* @param string $delimiter Delim to use * @param array $args CLI command list
* @param string $enclosure Enclosure to use
* @param string $escape Escape to use
* *
* @return string * @return string
* *
@ -251,7 +249,7 @@ class ArrayUtils
* *
* Reduces multi dimensional array to one dimensional array. Flatten tries to maintain the index as far as possible. * Reduces multi dimensional array to one dimensional array. Flatten tries to maintain the index as far as possible.
* *
* @param array $array Multi dimensional array to flatten * @param array $array Multi dimensional array to flatten
* *
* @return array * @return array
* *
@ -278,18 +276,25 @@ class ArrayUtils
} }
/** /**
* todo: what did i smoke? what is this? * Sum of array elements
*
* @param array $array Array to sum
* @param int $start Start index
* @param int $count Amount of elements to sum
*
* @return int|float
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public static function arraySum(array $array, int $start = 0, int $count = 0) public static function arraySum(array $array, int $start = 0, int $count = 0)
{ {
$count = $count === 0 ? count($array) : $count; $count = $count === 0 ? count($array) : $count;
$sum = 0.0; $sum = 0;
$array = array_values($array);
for ($i = $start; $i <= $count - 1; $i++) { for ($i = $start; $i <= $count - 1; $i++) {
if (!isset($array[$i])) {
continue;
}
$sum += $array[$i]; $sum += $array[$i];
} }

View File

@ -124,7 +124,8 @@ abstract class C128Abstract
* Constructor * Constructor
* *
* @param string $content Content to encrypt * @param string $content Content to encrypt
* @param int $size Barcode height * @param int $width Barcode width
* @param int $height Barcode height
* @param int $orientation Orientation of the barcode * @param int $orientation Orientation of the barcode
* *
* @todo : add mirror parameter * @todo : add mirror parameter
@ -142,7 +143,7 @@ abstract class C128Abstract
/** /**
* Set barcode dimensions * Set barcode dimensions
* *
* @param int $width Barcode width * @param int $width Barcode width
* @param int $height Barcode height * @param int $height Barcode height
* *
* @since 1.0.0 * @since 1.0.0
@ -158,7 +159,7 @@ abstract class C128Abstract
throw new \OutOfBoundsException($height); throw new \OutOfBoundsException($height);
} }
$this->dimension['width'] = $width; $this->dimension['width'] = $width;
$this->dimension['height'] = $height; $this->dimension['height'] = $height;
} }

View File

@ -45,12 +45,12 @@ class HIBCC
public function setIdentifier(string $identifier) /* : void */ public function setIdentifier(string $identifier) /* : void */
{ {
$this->identifer = $identifier; $this->identifier = $identifier;
} }
public function getIdentifier() : string public function getIdentifier() : string
{ {
return $this->identifer; return $this->identifier;
} }
public function setProductId(string $id) /* : void */ public function setProductId(string $id) /* : void */
@ -88,7 +88,7 @@ class HIBCC
$this->expirationDate = $date; $this->expirationDate = $date;
} }
public function getExpirationDate() : \Datetime public function getExpirationDate() : \DateTime
{ {
return $this->expirationDate; return $this->expirationDate;
} }

View File

@ -31,8 +31,8 @@ class Schedule extends TaskAbstract implements \Serializable
/** /**
* Constructor. * Constructor.
* *
* @param Interval $interval Interval * @param string $name Schedule name
* @param string $cmd Command to execute * @param string $cmd Command to execute
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>

View File

@ -14,6 +14,7 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Utils\TaskSchedule; namespace phpOMS\Utils\TaskSchedule;
use phpOMS\System\File\PathException;
/** /**
* Scheduler abstract. * Scheduler abstract.

View File

@ -35,7 +35,7 @@ final class SchedulerFactory
/** /**
* Create scheduler instance. * Create scheduler instance.
* *
* @return ScheduleInterface * @return SchedulerAbstract
* *
* @throws \Exception * @throws \Exception
* *

View File

@ -195,7 +195,7 @@ abstract class TaskAbstract
*/ */
public function setNextRunTime(\DateTime $nextRunTime) /* : void */ public function setNextRunTime(\DateTime $nextRunTime) /* : void */
{ {
$this->nextRuntime = $nextRunTime; $this->nextRunTime = $nextRunTime;
} }
/** /**

View File

@ -38,7 +38,7 @@ final class TaskFactory
* @param string $id Task id * @param string $id Task id
* @param string $cmd Command to run * @param string $cmd Command to run
* *
* @return TaskInterface * @return TaskAbstract
* *
* @throws \Exception * @throws \Exception
* *

View File

@ -43,7 +43,7 @@ class TaskScheduler extends SchedulerAbstract
* *
* @param string $cmd Command to run * @param string $cmd Command to run
* *
* @return array * @return string
* *
* @throws \Exception * @throws \Exception
* *
@ -114,7 +114,7 @@ class TaskScheduler extends SchedulerAbstract
} }
if(DateTime::isValid($jobData[5])) { if(DateTime::isValid($jobData[5])) {
$job->setLastRunTime(new \DateTime($jobData[5])); $job->setLastRuntime(new \DateTime($jobData[5]));
} }
$job->setAuthor($jobData[7]); $job->setAuthor($jobData[7]);
@ -171,7 +171,7 @@ class TaskScheduler extends SchedulerAbstract
public function getAllByName(string $name, bool $exact = true) : array public function getAllByName(string $name, bool $exact = true) : array
{ {
if($exact) { if($exact) {
$lines = $this->run('/query /v /fo CSV /tn ' . escapeshellarg($name)); $lines = explode("\n", $this->normalize($this->run('/query /v /fo CSV /tn ' . escapeshellarg($name))));
unset($lines[0]); unset($lines[0]);
$jobs = []; $jobs = [];

View File

@ -197,23 +197,23 @@ class View extends ViewAbstract
} }
/** /**
* @return Request * @return RequestAbstract
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getRequest() : Request public function getRequest() : RequestAbstract
{ {
return $this->request; return $this->request;
} }
/** /**
* @return Response * @return ResponseAbstract
* *
* @since 1.0.0 * @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com> * @author Dennis Eichhorn <d.eichhorn@oms.com>
*/ */
public function getResponse() : Response public function getResponse() : ResponseAbstract
{ {
return $this->response; return $this->response;
} }