mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
161 lines
2.9 KiB
PHP
161 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.2
|
|
*
|
|
* @package phpOMS\Math\Stochastic\Distribution
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://website.orange-management.de
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS\Math\Stochastic\Distribution;
|
|
|
|
/**
|
|
* Exponential distribution.
|
|
*
|
|
* @package phpOMS\Math\Stochastic\Distribution
|
|
* @license OMS License 1.0
|
|
* @link http://website.orange-management.de
|
|
* @since 1.0.0
|
|
*/
|
|
class ExponentialDistribution
|
|
{
|
|
/**
|
|
* Get probability density function.
|
|
*
|
|
* @param float $x Value x
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getPdf(float $x, float $lambda) : float
|
|
{
|
|
return $x >= 0 ? $lambda * \exp(-$lambda * $x) : 0;
|
|
}
|
|
|
|
/**
|
|
* Get cumulative distribution function.
|
|
*
|
|
* @param float $x Value x
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getCdf(float $x, float $lambda) : float
|
|
{
|
|
return $x >= 0 ? 1 - \exp($lambda * $x) : 0;
|
|
}
|
|
|
|
/**
|
|
* Get mode.
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMode() : float
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Get expected value.
|
|
*
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMean(float $lambda) : float
|
|
{
|
|
return 1 / $lambda;
|
|
}
|
|
|
|
/**
|
|
* Get expected value.
|
|
*
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMedian(float $lambda) : float
|
|
{
|
|
return 1 / $lambda;
|
|
}
|
|
|
|
/**
|
|
* Get variance.
|
|
*
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getVariance(float $lambda) : float
|
|
{
|
|
return \pow($lambda, -2);
|
|
}
|
|
|
|
/**
|
|
* Get moment generating function.
|
|
*
|
|
* @param float $t Value t
|
|
* @param float $lambda Lambda
|
|
*
|
|
* @return float
|
|
*
|
|
* @throws \Exception
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getMgf(float $t, float $lambda) : float
|
|
{
|
|
if ($t >= $lambda) {
|
|
throw new \Exception('Out of bounds');
|
|
}
|
|
|
|
return $lambda / ($lambda - $t);
|
|
}
|
|
|
|
/**
|
|
* Get skewness.
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getSkewness() : float
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
/**
|
|
* Get Ex. kurtosis.
|
|
*
|
|
* @return float
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
public static function getExKurtosis() : float
|
|
{
|
|
return 6;
|
|
}
|
|
|
|
public static function getRandom()
|
|
{
|
|
|
|
}
|
|
}
|