Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Eichhorn committed Oct 22, 2023
1 parent f435905 commit 1e19737
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Math/Solver/Root/Illinois.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public static function root(callable $func, float $a, float $b, int $maxIteratio
++$iteration;
}

return ($a + $b) / 2;
return $c;
}
}
2 changes: 1 addition & 1 deletion Math/Solver/Root/RegulaFalsi.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public static function root(callable $func, float $a, float $b, int $maxIteratio
++$iteration;
}

return ($a + $b) / 2;
return $c;
}
}
32 changes: 16 additions & 16 deletions Math/Topology/Kernel2D.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Kernels.
*
* The bandwidth in the following functions is equivalent with sigma.
* The bandwidth in the following functions is equivalent with 2 * sigma.
*
* @package phpOMS\Math\Topology
* @license OMS License 2.0
Expand Down Expand Up @@ -82,10 +82,10 @@ public static function triangularKernel(float $distance, float $bandwidth) : flo
*/
public static function epanechnikovKernel(float $distance, float $bandwidth) : float
{
if (\abs($distance) <= $bandwidth) {
$u = \abs($distance) / $bandwidth;
if (\abs($distance) <= $bandwidth / 2) {
$u = \abs($distance) / ($bandwidth / 2);

return 0.75 * (1 - $u * $u) / $bandwidth;
return 0.75 * (1 - $u * $u) / ($bandwidth / 2);
} else {
return 0.0;
}
Expand All @@ -103,10 +103,10 @@ public static function epanechnikovKernel(float $distance, float $bandwidth) : f
*/
public static function quarticKernel(float $distance, float $bandwidth) : float
{
if (\abs($distance) <= $bandwidth) {
$u = \abs($distance) / $bandwidth;
if (\abs($distance) <= $bandwidth / 2) {
$u = \abs($distance) / ($bandwidth / 2);

return (15 / 16) * (1 - $u * $u) * (1 - $u * $u) / $bandwidth;
return (15 / 16) * (1 - $u * $u) * (1 - $u * $u) / ($bandwidth / 2);
} else {
return 0.0;
}
Expand All @@ -124,10 +124,10 @@ public static function quarticKernel(float $distance, float $bandwidth) : float
*/
public static function triweightKernel(float $distance, float $bandwidth) : float
{
if (\abs($distance) <= $bandwidth) {
$u = \abs($distance) / $bandwidth;
if (\abs($distance) <= $bandwidth / 2) {
$u = \abs($distance) / ($bandwidth / 2);

return (35 / 32) * (1 - $u * $u) * (1 - $u * $u) * (1 - $u * $u) / $bandwidth;
return (35 / 32) * (1 - $u * $u) * (1 - $u * $u) * (1 - $u * $u) / ($bandwidth / 2);
} else {
return 0.0;
}
Expand All @@ -145,10 +145,10 @@ public static function triweightKernel(float $distance, float $bandwidth) : floa
*/
public static function tricubeKernel(float $distance, float $bandwidth) : float
{
if (\abs($distance) <= $bandwidth) {
$u = \abs($distance) / $bandwidth;
if (\abs($distance) <= $bandwidth / 2) {
$u = \abs($distance) / ($bandwidth / 2);

return (70 / 81) * (1 - $u * $u * $u) * (1 - $u * $u * $u) * (1 - $u * $u * $u) / $bandwidth;
return (70 / 81) * (1 - $u * $u * $u) * (1 - $u * $u * $u) * (1 - $u * $u * $u) / ($bandwidth / 2);
} else {
return 0.0;
}
Expand Down Expand Up @@ -181,8 +181,8 @@ public static function gaussianKernel(float $distance, float $bandwidth) : float
*/
public static function cosineKernel(float $distance, float $bandwidth) : float
{
return \abs($distance) <= $bandwidth
? (\M_PI / 4) * \cos(\M_PI * $distance / (2 * $bandwidth)) / $bandwidth
return \abs($distance) <= $bandwidth / 2
? (\M_PI / 4) * \cos(\M_PI * $distance / $bandwidth) / ($bandwidth / 2)
: 0.0;
}

Expand All @@ -198,6 +198,6 @@ public static function cosineKernel(float $distance, float $bandwidth) : float
*/
public static function logisticKernel(float $distance, float $bandwidth) : float
{
return 1 / (\exp($distance / $bandwidth) + 2 + \exp(-$distance / $bandwidth));
return 1 / (\exp($distance / ($bandwidth / 2)) + 2 + \exp(-$distance / ($bandwidth / 2)));
}
}
2 changes: 1 addition & 1 deletion Message/ResponseAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class ResponseAbstract implements \JsonSerializable, MessageInterface
*
* @since 1.0.0
*/
public function getData(mixed $key, string $type = null) : mixed
public function getData(mixed $key = null, string $type = null) : mixed
{
if ($key === null) {
return $this->data;
Expand Down

0 comments on commit 1e19737

Please sign in to comment.