Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #372

Merged
merged 7 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Algorithm/Rating/Glicko1.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function calculateC(int $ratingPeriods = 100, int $avgRD = 50) : void
}

/**
* Calcualte the glicko-1 elo
* Calculate the glicko-1 elo
*
* @param int $elo Current player "elo"
* @param int $rdOld Current player deviation (RD)
Expand Down
2 changes: 1 addition & 1 deletion Algorithm/Rating/Glicko2.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final class Glicko2
public int $MIN_RD = 50;

/**
* Calcualte the glicko-2 elo
* Calculate the glicko-2 elo
*
* @example $glicko->elo(1500, 200, 0.06, [1,0,0], [1400,1550,1700], [30,100,300]) // 1464, 151, 0.059
*
Expand Down
6 changes: 2 additions & 4 deletions Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ public static function inClassMap(string $map) : bool
*/
public static function findPaths(string $class) : array
{
$found = [];
$class = \ltrim($class, '\\');
$class = \strtr($class, '_\\', '//');

Expand All @@ -143,12 +142,11 @@ public static function findPaths(string $class) : array
$subclass = $nspacePos === false ? '' : \substr($class, 0, $nspacePos);

if (isset(self::$classmap[$subclass])) {
$found[] = self::$classmap[$subclass] . $class . '.php';

return $found;
return [self::$classmap[$subclass] . $class . '.php'];
}
}

$found = [];
foreach (self::$paths as $path) {
if (\is_file($file = $path . $class . '.php')) {
$found[] = $file;
Expand Down
2 changes: 1 addition & 1 deletion Business/Finance/Depreciation.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function __construct()
}

/**
* Calculate linear depretiation rate
* Calculate linear depreciation rate
*
* @param float $start Value to depreciate
* @param int $duration Useful life time
Expand Down
2 changes: 1 addition & 1 deletion Business/Finance/DepreciationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class DepreciationType extends Enum
{
public const NONE = 1;

public const STAIGHT_LINE = 2;
public const STRAIGHT_LINE = 2;

public const DECLINING_BALANCE = 3;

Expand Down
14 changes: 7 additions & 7 deletions Business/Finance/FinanceFormulas.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function getPeriodicPaymentOfFVA(float $fva, float $r, int $n) : f
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $cf Cach flow
* @param float $cf Cashflow
* @param float $r Rate
* @param int $t Time
*
Expand All @@ -143,7 +143,7 @@ public static function getFutureValueOfAnnuityConinuousCompounding(float $cf, fl
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $fvacc Future value annuity continuous compoinding
* @param float $fvacc Future value annuity continuous compounding
* @param float $r Rate
* @param int $t Time
*
Expand All @@ -159,8 +159,8 @@ public static function getCashFlowOfFVACC(float $fvacc, float $r, int $t) : floa
/**
* Annuity - Future Value w/ Continuous Compounding
*
* @param float $fvacc Future value annuity continuous compoinding
* @param float $cf Cach flow
* @param float $fvacc Future value annuity continuous compounding
* @param float $cf Cashflow
* @param float $r Rate
*
* @return int
Expand Down Expand Up @@ -766,7 +766,7 @@ public static function getDoublingTime(float $r) : float
}

/**
* Get rate to dobule
* Get rate to double
*
* @param float $t Time in which to double investment
*
Expand Down Expand Up @@ -859,7 +859,7 @@ public static function getNetPresentValueOfEAA(float $C, float $r, int $n) : flo
* Free Cash Flow to Equity (FCFE = FCFF - dept payments)
*
* @param float $income Net income
* @param float $depamo Depreciation & amortisation
* @param float $depamo Depreciation & amortization
* @param float $capital Capital expenses
* @param float $wc Change in working capital
* @param float $borrowing Net Borrowing
Expand All @@ -878,7 +878,7 @@ public static function getFreeCashFlowToEquity(float $income, float $depamo, flo
*
* @param float $ebit EBIT
* @param float $t Tax rate
* @param float $depamo Depreciation & amortisation
* @param float $depamo Depreciation & amortization
* @param float $capital Capital expenses
* @param float $wc Change in working capital
*
Expand Down
4 changes: 2 additions & 2 deletions Business/Finance/Lorenzkurve.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ private function __construct()
/**
* Calculate Gini coefficient
*
* @param array<int|float> $data Datapoints (can be unsorted)
* @param array<int|float> $data Data points (can be unsorted)
*
* @return float Returns the gini coefficient
* @return float Returns the Gini coefficient
*
* @since 1.0.0
*/
Expand Down
20 changes: 10 additions & 10 deletions Business/Marketing/Metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function getCustomerRetention(int $ce, int $cn, int $cs) : float
}

/**
* Calcualte the coefficient of retention
* Calculate the coefficient of retention
*
* @param float $retentionRate Observed retention rate (optionally use the average)
* @param float $rc Retention rate ceiling
Expand Down Expand Up @@ -109,21 +109,21 @@ public static function customerActiveProbability(int $purchases, int $periods, i
/**
* Calculate the customer profits
*
* @param int $customers Amount of customers acquired
* @param float $acquistionCost Acquisition cost per customer
* @param float $revenue Revenues per period per customer
* @param float $cogs COGS per period per customer
* @param float $marketingCosts Ongoing marketing costs per period per customer
* @param float $discountRate Discount rate
* @param float $retentionRate Retention rate (how many customers remain)
* @param int $customers Amount of customers acquired
* @param float $acquisitionCost Acquisition cost per customer
* @param float $revenue Revenues per period per customer
* @param float $cogs COGS per period per customer
* @param float $marketingCosts Ongoing marketing costs per period per customer
* @param float $discountRate Discount rate
* @param float $retentionRate Retention rate (how many customers remain)
*
* @return float
*
* @since 1.0.0
*/
public static function getBerrysCustomerProfits(
int $customers,
float $acquistionCost,
float $acquisitionCost,
float $revenue,
float $cogs,
float $marketingCosts,
Expand All @@ -133,7 +133,7 @@ public static function getBerrysCustomerProfits(
{
return $customers * ($revenue - $cogs) * ((1 + $discountRate) / (1 + $discountRate - $retentionRate))
- $customers * $marketingCosts * ((1 + $discountRate) / (1 + $discountRate - $retentionRate))
- $customers * $acquistionCost;
- $customers * $acquisitionCost;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Business/Marketing/NetPromoterScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function add(int $score) : void
*
* @latex NPS = Promoters - Detractors
*
* @return int Retunrs the NPS
* @return int NPS
*
* @since 1.0.0
*/
Expand Down
2 changes: 1 addition & 1 deletion Business/Marketing/PageRank.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function __construct(array $relations, bool $isUnique = true, float $damp
}

/**
* Calcualte the rank based on a start rank for the different elements
* Calculate the rank based on a start rank for the different elements
*
* A different start rank for different elements might make sense if the elements are not uniform from the very beginning
*
Expand Down
2 changes: 1 addition & 1 deletion Business/Recommendation/ArticleCorrelationAffinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ArticleCorrelationAffinity
/**
* Item order behavior (when are which items ordered)
*
* In tearms of the pearson correlation these are our random variables
* In terms of the pearson correlation these are our random variables
*
* @var array
* @since 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion Business/Recommendation/ModelCF.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private function __construct()
* the item matrix contains in every row a score for how much it belongs to a certain attribute. Each column represents an item.
* example: users columns define how much a user likes a certain movie genre and the item rows define how much this movie belongs to a certain genre.
* the multiplication gives a score of how much the user may like that movie.
* A segnificant amount of attributes are required to calculate a good match
* A significant amount of attributes are required to calculate a good match
*
* @param array<int|string, array<int|float>> $users A mxa matrix where each "m" defines how much the user likes a certain attribute type and "a" defines different users
* @param array<int|string, array<int|float>> $items A bxm matrix where each "b" defines a item and "m" defines how much it belongs to a certain attribute type
Expand Down
4 changes: 2 additions & 2 deletions Business/Sales/MarketShareEstimation.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function __construct()
*
* @latex r = \sqrt[s]{\frac{1}{m \times \sum_{n=1}^N{\frac{1}{n^{s}}}}}
*
* @param int $participants The amount of existing participants in the market or compentitors (N)
* @param int $participants The amount of existing participants in the market or competitors (N)
* @param float $marketShare The absolute own market share (m)
* @param float $modifier Distribution modifier (s)
*
Expand All @@ -65,7 +65,7 @@ public static function getRankFromMarketShare(int $participants, float $marketSh
*
* @latex m = \frac{\frac{1}{r^{s}}}{\sum_{n=1}^N{\frac{1}{n^{s}}}}
*
* @param int $participants The amount of existing participants in the market or compentitors (N)
* @param int $participants The amount of existing participants in the market or competitors (N)
* @param int $rank The absolute own rank in the market (r)
* @param float $modifier Distribution modifier (s)
*
Expand Down
8 changes: 4 additions & 4 deletions DataStorage/Database/Mapper/DeleteMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,15 @@ private function deleteHasMany(object $obj, mixed $objId, ?\ReflectionClass &$re
/**
* Delete has many relations if the relation is handled in a relation table
*
* @param string $member Property which contains the has many models
* @param array $objIds Objects which are related to the parent object
* @param mixed $objId Parent object id
* @param string $member Property which contains the has many models
* @param null|array $objIds Objects which are related to the parent object
* @param mixed $objId Parent object id
*
* @return void
*
* @since 1.0.0
*/
public function deleteRelationTable(string $member, ?array $objIds = null, mixed $objId) : void
public function deleteRelationTable(string $member, ?array $objIds, mixed $objId) : void
{
if ((empty($objIds) && $objIds !== null)
|| $this->mapper::HAS_MANY[$member]['table'] === $this->mapper::TABLE
Expand Down
8 changes: 4 additions & 4 deletions DataStorage/Database/Schema/Grammar/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ protected function compileCreateFields(SchemaBuilder $query, array $fields) : st
$fieldQuery .= ' ' . ($field['null'] ? '' : 'NOT ') . 'NULL';
}

if ($field['primary'] ?? false) {
$keys .= ' PRIMARY KEY';
}

if ($field['autoincrement'] ?? false) {
$fieldQuery .= ' AUTOINCREMENT';
}

if ($field['primary'] ?? false) {
$fieldQuery .= ' PRIMARY KEY';
}

$fieldQuery .= ',';

if ($field['unique'] ?? false) {
Expand Down
4 changes: 2 additions & 2 deletions Dispatcher/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class Dispatcher implements DispatcherInterface
/**
* Constructor.
*
* @param ApplicationAbstract $app Appliaction
* @param ApplicationAbstract $app Application
*
* @since 1.0.0
*/
Expand Down Expand Up @@ -78,7 +78,7 @@ public function dispatch(array | string | callable $controller, mixed ...$data)
}

// Php void functions always return null.
// In a different language the Api functions would reguire a return type
// In a different language the Api functions would require a return type
// If null is returned (i.e. void functions) these get ignored later in the response renderer as null is not "rendered"
if (\is_string($controller)) {
$views += $this->dispatchString($controller, $data);
Expand Down
8 changes: 4 additions & 4 deletions Log/FileLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function log(string $level, string $message, array $context = []) : void
}

/**
* Analyse logging file.
* Analyze logging file.
*
* @return array
*
Expand Down Expand Up @@ -414,9 +414,9 @@ public function countLogs() : array
}

/**
* Find cricitcal connections.
* Find critical connections.
*
* @param int $limit Amout of perpetrators
* @param int $limit Amount of perpetrators
*
* @return array
*
Expand Down Expand Up @@ -464,7 +464,7 @@ public function getHighestPerpetrator(int $limit = 10) : array
/**
* Get logging messages from file.
*
* @param int $limit Amout of logs
* @param int $limit Amount of logs
* @param int $offset Offset
*
* @return array
Expand Down
2 changes: 1 addition & 1 deletion Math/Functions/Algebra.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function mult(array $value1, array $value2) : int|float|array

if (!$isMatrix1 && $isMatrix2) {
$temp = $value1;
$value1 = $value1;
$value1 = $value2;
$value2 = $temp;

$m1 = \count($value1);
Expand Down
6 changes: 3 additions & 3 deletions Math/Matrix/CholeskyDecomposition.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/**
* Cholesky decomposition
*
* A is syymetric, positive definite then A = L*L'
* A is symmetric, positive definite then A = L*L'
*
* @package phpOMS\Math\Matrix
* @license OMS License 2.0
Expand All @@ -46,7 +46,7 @@ final class CholeskyDecomposition
private int $m = 0;

/**
* Is symmetric positiv definite
* Is symmetric positive definite
*
* @var bool
* @since 1.0.0
Expand Down Expand Up @@ -89,7 +89,7 @@ public function __construct(Matrix $M)
}

/**
* Is matrix symmetric positiv definite.
* Is matrix symmetric positive definite.
*
* @return bool
*
Expand Down
21 changes: 8 additions & 13 deletions Math/Matrix/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,32 +841,27 @@ public function pow(int | float $exponent) : self
*
* The algorithm uses a taylor series.
*
* @param int $iterations Iterations for approximation
*
* @return self
*
* @since 1.0.0
*/
public function exp(int $iterations = 10) : self
public function exp() : self
{
if ($this->m !== $this->n) {
throw new InvalidDimensionException($this->m . 'x' . $this->n);
}

$sum = new IdentityMatrix($this->m);

$factorial = 1;
$pow = clone $sum;
$eig = new EigenvalueDecomposition($this);
$v = $eig->getV();
$d = $eig->getD();

for ($i = 1; $i <= $iterations; ++$i) {
$factorial *= $i;
$coeff = 1 / $factorial;
$vInv = $v->inverse();

$pow = $pow->mult($this);
$sum = $sum->add($pow->mult($coeff));
for ($i = 0; $i < $this->m; ++$i) {
$d->matrix[$i][$i] = \exp($d->matrix[$i][$i]);
}

return $sum;
return $v->mult($d)->mult($vInv);
}

/**
Expand Down
Loading
Loading