### Functionality

This class has a list of basic statistical functions such as the mean, variance, standard deviation, asymmetry, etc., and it works well, executing these functions in the last 30 days.

It extends to a parent class that estimates future prices very close to a list of actions using an API delayed in 60-second data.

Would you be so kind and possibly revise it to know performance, efficiency, mathematics or coding best practices?

### Code

```
// Config class for route and other constants
require_once __DIR__. "/ConstEQ.php";
/ **
* This is an extended class with basic statistical method.
* Values
* /
The ST class extends the ConstEQ equalization tools
{
/ **
*
* @return a number equal to the average of the values of a matrix
* /
Public static function getMean ($ array)
{
if (count ($ array) == 0) {
returns ConstEQ: NEAR_ZERO_NUMBER;
} else {
return array_sum ($ array) / count ($ array);
}
}
/ **
*
* @ Return a normalized number between 0 and 1
* /
static public function getNormalize ($ value, $ min, $ max)
{
yes ($ max - $ min! = 0) {
$ normalized = 2 * (($ value - $ min) / ($ max - $ min)) - 1;
} else {
$ normalized = 2 * (($ value - $ min)) - 1;
}
returns $ normalized;
}
/ **
*
* @ Return a normalized number between 0.0 to 1 from any input -inf to inf
* /
Static public function getSigmoid ($ t)
{
returns 1 / (1 + pow (M_EULER, - $ t));
}
/ **
*
* @return a number equal to the square of the average value
* /
static public function getMeanSquare ($ x, $ average)
{return pow ($ x - $ mean, 2);}
/ **
*
* @return a number equal to the standard deviation of the values of a matrix
* /
Static public function getStandardDeviation ($ array)
{
yes (account ($ array) <2) {
returns ConstEQ: NEAR_ZERO_NUMBER;
} else {
return sqrt (array_sum (array_map ("ST :: getMeanSquare", $ array, array_fill (0, count ($ array), (array_sum ($ array) / count ($ array)))))) / (count ($ array ) - one));
}
}
/ **
*
* @return a number equal to the covariance of values of two matrices
* /
Public static function getCovariance ($ valuesA, $ valuesB)
{
// size both equal matrices, if they are of different sizes
$ no_keys = min (count ($ valuesA), count ($ valuesB));
$ valuesA = array_slice ($ valuesA, 0, $ no_keys);
$ valuesB = array_slice ($ valuesB, 0, $ no_keys);
// if the size of the matrices is too small
if ($ no_keys <2) {return ConstEQ :: NEAR_ZERO_NUMBER;}
// Use the library function if available
if (function_exists (& # 39; stats_covariance & # 39;)) {return stats_covariance ($ valuesA, $ valuesB);}
$ meanA = array_sum ($ valuesA) / $ no_keys;
$ meanB = array_sum ($ valuesB) / $ no_keys;
$ add = 0.0;
for ($ pos = 0; $ pos <$ no_keys; $ pos ++) {
$ valueA = $ valuesA[$pos];
if (! is_numeric ($ valueA)) {
trigger_error (& # 39; Non-numeric value in matrix A in position & # 39 ;. $ pos. & # 39 ;, value = & # 39 ;. $ valueA, E_USER_WARNING);
false return;
}
$ valueB = $ valuesB[$pos];
if (! is_numeric ($ valueB)) {
trigger_error (& # 39; Non-numeric value in matrix B at position & # 39 ;. $ pos. & # 39 ;, value = & # 39 ;. $ valueB, E_USER_WARNING);
false return;
}
$ difA = $ valueA - $ meanA;
$ difB = $ valueB - $ meanB;
$ add + = ($ difA * $ difB);
}
returns $ add / $ no_keys;
}
/ **
*
* @Serve a number equal to the bias of the values of the matrix
* /
Static public function getSkewness ($ values)
{
$ numValues = count ($ values);
if ($ numValues == 0) {return 0.0;}
// Use the function of the php_stats library if it is available
if (function_exists (& # 39; stats_skew & # 39;)) {return stats_skew ($ values);}
$ media = array_sum ($ values) / floatval ($ numValues);
$ add2 = 0.0;
$ add3 = 0.0;
foreach ($ values as $ value) {
if (! is_numeric ($ value)) {return false;}
$ dif = $ value - $ average;
$ add2 + = ($ dif * $ dif);
$ add3 + = ($ dif * $ dif * $ dif);
}
$ variance = $ add2 / floatval ($ numValues);
if ($ variance == 0) {return ConstEQ :: NEAR_ZERO_NUMBER;} else {return ($ add3 / floatval ($ numValues)) / pow ($ variance, 3 / 2.0);}
}
/ **
*
* @serving a number equal to the kurtosis of the matrix values
* /
Public static function getKurtosis ($ values)
{
$ numValues = count ($ values);
if ($ numValues == 0) {return 0.0;}
// Use the function of the php_stats library if it is available
if (function_exists (& # 39; stats_kurtosis & # 39;)) {return stats_kurtosis ($ values);}
$ media = array_sum ($ values) / floatval ($ numValues);
$ add2 = 0.0;
$ add4 = 0.0;
foreach ($ values as $ value) {
if (! is_numeric ($ value)) {return false;}
$ dif = $ value - $ average;
$ dif2 = $ dif * $ dif;
$ add2 + = $ dif2;
$ add4 + = ($ dif2 * $ dif2);
}
$ variance = $ add2 / floatval ($ numValues);
if ($ variance == 0) {return ConstEQ :: NEAR_ZERO_NUMBER;} else {return ($ add4 * $ numValues) / ($ add2 * $ add2) - 3.0;}
}
/ **
*
* @ returns a number equal to the correlation of two matrices
* /
Public static function getCorrelation ($ arr1, $ arr2)
{
$ correlation = 0;
$ k = ST :: sumProductMeanDeviation ($ arr1, $ arr2);
$ ssmd1 = ST :: sumSquareMeanDeviation ($ arr1);
$ ssmd2 = ST :: sumSquareMeanDeviation ($ arr2);
$ product = $ ssmd1 * $ ssmd2;
$ res = sqrt ($ product);
if ($ res == 0) {return ConstEQ :: NEAR_ZERO_NUMBER;}
$ correlation = $ k / $ res;
if ($ correlation == 0) {return ConstEQ :: NEAR_ZERO_NUMBER;} else {return $ correlation;}
}
/ **
*
* @detain a number equal to the sum of the average product deviation of each matrix value
* /
public static function sumProductMeanDeviation ($ arr1, $ arr2)
{
$ sum = 0;
$ num = count ($ arr1);
for ($ i = 0; $ i <$ num; $ i ++) {$ sum = $ sum + ST :: productMeanDeviation ($ arr1, $ arr2, $ i);}
returns $ sum;
}
/ **
*
* @serving a number equal to the average product deviation of each matrix value
* /
public static function productMeanDeviation ($ arr1, $ arr2, $ item)
{return (ST :: meanDeviation ($ arr1, $ item) * ST :: meanDeviation ($ arr2, $ item));}
/ **
*
* @return a number equal to the sum of the mean square deviation of the values of each matrix
* /
Public static function sumSquareMeanDeviation ($ arr)
{
$ sum = 0;
$ num = count ($ arr);
for ($ i = 0; $ i <$ num; $ i ++) {$ sum = $ sum + ST :: squareMeanDeviation ($ arr, $ i);}
returns $ sum;
}
/ **
*
* @return a number equal to the mean square deviation of the values of each matrix
* /
public static function squareMeanDeviation ($ arr, $ item)
{
return ST :: meanDeviation ($ arr, $ item) * ST :: meanDeviation ($ arr, $ item);
}
/ **
*
* @return a number equal to the sum of the average deviation of the values of each matrix
* /
public static function sumMeanDeviation ($ arr)
{
$ sum = 0;
$ num = count ($ arr);
for ($ i = 0; $ i <$ num; $ i ++) {$ sum = $ sum + ST :: meanDeviation ($ arr, $ i);}
returns $ sum;
}
/ **
*
* @ returns a number equal to the average deviation of the values of each matrix
* /
public static function meanDeviation ($ arr, $ item)
{
$ average = ST :: average ($ arr); return $ arr[$item] - average $;
}
/ **
*
* @remits a number equal to the average of the values in the matrix
* /
average public static function ($ arr)
{
$ sum = ST :: sum ($ arr);
$ num = count ($ arr); returns $ sum / $ num;}
/ **
*
* @return a number equal to the sum of a matrix
* /
sum of the public static function ($ arr)
{return array_sum ($ arr);}
/ **
*
* @Back a series of coefficients for 7 levels of volatilities
* /
public static function getCoefParams ($ overall_market_coeff)
{
$ daily_coef = 0.9 + ($ overall_market_coeff / 10);
$ coefs = array (
ConstEQ :: LEVEL_VOLATILITY_COEF_1 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_2 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_3 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_4 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_5 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_6 * $ daily_coef,
ConstEQ :: LEVEL_VOLATILITY_COEF_7 * $ daily_coef,
);
returns $ coefs;
}
/ **
* @return a true or false binary for the is_numeric test of a string
* /
The public static function is Number ($ arr)
{
foreach ($ arr as $ b) {
yes (! is_numeric ($ b)) {
false return;
}
}
true returns
}
}
```