PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / Statistical / Distributions / Fisher.php

Fisher.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php

73 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\Statistical\Distributions;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
6 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
7 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
8
9 class Fisher
10 {
11 use ArrayEnabled;
12
13 /**
14 * FISHER.
15 *
16 * Returns the Fisher transformation at x. This transformation produces a function that
17 * is normally distributed rather than skewed. Use this function to perform hypothesis
18 * testing on the correlation coefficient.
19 *
20 * @param mixed $value Float value for which we want the probability
21 * Or can be an array of values
22 *
23 * @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
24 * with the same dimensions
25 */
26 public static function distribution($value)
27 {
28 if (is_array($value)) {
29 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value);
30 }
31
32 try {
33 $value = DistributionValidations::validateFloat($value);
34 } catch (Exception $e) {
35 return $e->getMessage();
36 }
37
38 if (($value <= -1) || ($value >= 1)) {
39 return ExcelError::NAN();
40 }
41
42 return 0.5 * log((1 + $value) / (1 - $value));
43 }
44
45 /**
46 * FISHERINV.
47 *
48 * Returns the inverse of the Fisher transformation. Use this transformation when
49 * analyzing correlations between ranges or arrays of data. If y = FISHER(x), then
50 * FISHERINV(y) = x.
51 *
52 * @param mixed $probability Float probability at which you want to evaluate the distribution
53 * Or can be an array of values
54 *
55 * @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
56 * with the same dimensions
57 */
58 public static function inverse($probability)
59 {
60 if (is_array($probability)) {
61 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $probability);
62 }
63
64 try {
65 $probability = DistributionValidations::validateFloat($probability);
66 } catch (Exception $e) {
67 return $e->getMessage();
68 }
69
70 return (exp(2 * $probability) - 1) / (exp(2 * $probability) + 1);
71 }
72 }
73