fix tests

This commit is contained in:
Dennis Eichhorn 2023-10-22 18:26:48 +00:00
parent f435905146
commit 1e197375c5
4 changed files with 19 additions and 19 deletions

View File

@ -87,6 +87,6 @@ final class Illinois
++$iteration;
}
return ($a + $b) / 2;
return $c;
}
}

View File

@ -76,6 +76,6 @@ final class RegulaFalsi
++$iteration;
}
return ($a + $b) / 2;
return $c;
}
}

View File

@ -17,7 +17,7 @@ namespace phpOMS\Math\Topology;
/**
* 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
@ -82,10 +82,10 @@ final class Kernel2D
*/
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;
}
@ -103,10 +103,10 @@ final class Kernel2D
*/
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;
}
@ -124,10 +124,10 @@ final class Kernel2D
*/
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;
}
@ -145,10 +145,10 @@ final class Kernel2D
*/
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;
}
@ -181,8 +181,8 @@ final class Kernel2D
*/
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;
}
@ -198,6 +198,6 @@ final class Kernel2D
*/
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)));
}
}

View File

@ -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;