mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
153 lines
2.7 KiB
PHP
153 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.4
|
|
*
|
|
* @package phpOMS\Math\Stochastic\Distribution
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link https://orange-management.org
|
|
*/
|
|
declare(strict_types=1);
|
|
namespace phpOMS\Math\Stochastic\Distribution;
|
|
|
|
/**
|
|
* Logistic distribution.
|
|
*
|
|
* @package phpOMS\Math\Stochastic\Distribution
|
|
* @license OMS License 1.0
|
|
* @link https://orange-management.org
|
|
* @since 1.0.0
|
|
*/
|
|
class LogisticDistribution
|
|
{
|
|
/**
|
|
* Get probability density function.
|
|
*
|
|
* @param float $x Value x
|
|
* @param float $mu Mu location
|
|
* @param float $s s scale
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getPdf(float $x, float $mu, float $s) : float
|
|
{
|
|
return \exp(-($x - $mu) / $s)
|
|
/ ($s * (1 + \exp(-($x - $mu) / $s)) ** 2);
|
|
}
|
|
|
|
/**
|
|
* Get cummulative distribution function.
|
|
*
|
|
* @param float $x Value x
|
|
* @param float $mu Mu location
|
|
* @param float $s s scale
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getCdf(float $x, float $mu, float $s) : float
|
|
{
|
|
return 1 / (1 + \exp(-($x - $mu) / $s));
|
|
}
|
|
|
|
/**
|
|
* Get mode.
|
|
*
|
|
* @param float $mu Value mu
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMode(float $mu) : float
|
|
{
|
|
return $mu;
|
|
}
|
|
|
|
/**
|
|
* Get expected value.
|
|
*
|
|
* @param float $mu Value mu
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMean(float $mu) : float
|
|
{
|
|
return $mu;
|
|
}
|
|
|
|
/**
|
|
* Get median.
|
|
*
|
|
* @param float $mu Value mu
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMedian(float $mu) : float
|
|
{
|
|
return $mu;
|
|
}
|
|
|
|
/**
|
|
* Get variance.
|
|
*
|
|
* @param float $s s scale
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getVariance(float $s) : float
|
|
{
|
|
return $s ** 2 * \M_PI ** 2 / 3;
|
|
}
|
|
|
|
/**
|
|
* Get skewness.
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getSkewness() : float
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Get skewness.
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getExKurtosis() : float
|
|
{
|
|
return 6 / 5;
|
|
}
|
|
|
|
/**
|
|
* Get entropy.
|
|
*
|
|
* @param float $s s scale
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getEntropy(float $s) : float
|
|
{
|
|
return \log($s) + 2;
|
|
}
|
|
}
|