| 1 |
<?php |
| 2 |
|
| 3 |
namespace WP_DEFENDER_VENDOR\Safe; |
| 4 |
|
| 5 |
use WP_DEFENDER_VENDOR\Safe\Exceptions\StatsException; |
| 6 |
|
| 7 |
/** |
| 8 |
* Returns the covariance of a and b. |
| 9 |
* |
| 10 |
* @param array $a The first array |
| 11 |
* @param array $b The second array |
| 12 |
* @return float Returns the covariance of a and b. |
| 13 |
* @throws StatsException |
| 14 |
* |
| 15 |
*/ |
| 16 |
function stats_covariance(array $a, array $b): float |
| 17 |
{ |
| 18 |
error_clear_last(); |
| 19 |
$result = \stats_covariance($a, $b); |
| 20 |
if ($result === false) { |
| 21 |
throw StatsException::createFromPhpError(); |
| 22 |
} |
| 23 |
return $result; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* Returns the standard deviation of the values in a. |
| 29 |
* |
| 30 |
* @param array $a The array of data to find the standard deviation for. Note that all |
| 31 |
* values of the array will be cast to float. |
| 32 |
* @param bool $sample Indicates if a represents a sample of the |
| 33 |
* population; defaults to FALSE. |
| 34 |
* @return float Returns the standard deviation on success; FALSE on failure. |
| 35 |
* @throws StatsException |
| 36 |
* |
| 37 |
*/ |
| 38 |
function stats_standard_deviation(array $a, bool $sample = false): float |
| 39 |
{ |
| 40 |
error_clear_last(); |
| 41 |
$result = \stats_standard_deviation($a, $sample); |
| 42 |
if ($result === false) { |
| 43 |
throw StatsException::createFromPhpError(); |
| 44 |
} |
| 45 |
return $result; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
/** |
| 50 |
* Returns the Pearson correlation coefficient between arr1 and arr2. |
| 51 |
* |
| 52 |
* @param array $arr1 The first array |
| 53 |
* @param array $arr2 The second array |
| 54 |
* @return float Returns the Pearson correlation coefficient between arr1 and arr2. |
| 55 |
* @throws StatsException |
| 56 |
* |
| 57 |
*/ |
| 58 |
function stats_stat_correlation(array $arr1, array $arr2): float |
| 59 |
{ |
| 60 |
error_clear_last(); |
| 61 |
$result = \stats_stat_correlation($arr1, $arr2); |
| 62 |
if ($result === false) { |
| 63 |
throw StatsException::createFromPhpError(); |
| 64 |
} |
| 65 |
return $result; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
/** |
| 70 |
* Returns the inner product of arr1 and arr2. |
| 71 |
* |
| 72 |
* @param array $arr1 The first array |
| 73 |
* @param array $arr2 The second array |
| 74 |
* @return float Returns the inner product of arr1 and arr2. |
| 75 |
* @throws StatsException |
| 76 |
* |
| 77 |
*/ |
| 78 |
function stats_stat_innerproduct(array $arr1, array $arr2): float |
| 79 |
{ |
| 80 |
error_clear_last(); |
| 81 |
$result = \stats_stat_innerproduct($arr1, $arr2); |
| 82 |
if ($result === false) { |
| 83 |
throw StatsException::createFromPhpError(); |
| 84 |
} |
| 85 |
return $result; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
/** |
| 90 |
* Returns the variance of the values in a. |
| 91 |
* |
| 92 |
* @param array $a The array of data to find the standard deviation for. Note that all |
| 93 |
* values of the array will be cast to float. |
| 94 |
* @param bool $sample Indicates if a represents a sample of the |
| 95 |
* population; defaults to FALSE. |
| 96 |
* @return float Returns the variance on success; FALSE on failure. |
| 97 |
* @throws StatsException |
| 98 |
* |
| 99 |
*/ |
| 100 |
function stats_variance(array $a, bool $sample = false): float |
| 101 |
{ |
| 102 |
error_clear_last(); |
| 103 |
$result = \stats_variance($a, $sample); |
| 104 |
if ($result === false) { |
| 105 |
throw StatsException::createFromPhpError(); |
| 106 |
} |
| 107 |
return $result; |
| 108 |
} |
| 109 |
|