feat: Version 3.5.2 - Configuration Stripe et gestion des immeubles
- Configuration complète Stripe pour les 3 environnements (DEV/REC/PROD) * DEV: Clés TEST Pierre (mode test) * REC: Clés TEST Client (mode test) * PROD: Clés LIVE Client (mode live) - Ajout de la gestion des bases de données immeubles/bâtiments * Configuration buildings_database pour DEV/REC/PROD * Service BuildingService pour enrichissement des adresses - Optimisations pages et améliorations ergonomie - Mises à jour des dépendances Composer - Nettoyage des fichiers obsolètes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,8 @@ class Averages extends AggregateBase
|
||||
return ExcelError::VALUE();
|
||||
}
|
||||
if (self::isAcceptedCountable($arg, $k)) {
|
||||
/** @var float|int|numeric-string $arg */
|
||||
/** @var float|int|numeric-string $aMean */
|
||||
$returnValue += abs($arg - $aMean);
|
||||
++$aCount;
|
||||
}
|
||||
@@ -83,6 +85,7 @@ class Averages extends AggregateBase
|
||||
return ExcelError::VALUE();
|
||||
}
|
||||
if (self::isAcceptedCountable($arg, $k)) {
|
||||
/** @var float|int|numeric-string $arg */
|
||||
$returnValue += $arg;
|
||||
++$aCount;
|
||||
}
|
||||
@@ -153,6 +156,7 @@ class Averages extends AggregateBase
|
||||
|
||||
$returnValue = ExcelError::NAN();
|
||||
|
||||
/** @var array<float|int> */
|
||||
$aArgs = self::filterArguments($aArgs);
|
||||
$valueCount = count($aArgs);
|
||||
if ($valueCount > 0) {
|
||||
@@ -161,7 +165,7 @@ class Averages extends AggregateBase
|
||||
if ($valueCount == floor($valueCount)) {
|
||||
$returnValue = ($aArgs[$valueCount--] + $aArgs[$valueCount]) / 2;
|
||||
} else {
|
||||
$valueCount = floor($valueCount);
|
||||
$valueCount = (int) floor($valueCount);
|
||||
$returnValue = $aArgs[$valueCount];
|
||||
}
|
||||
}
|
||||
@@ -196,6 +200,11 @@ class Averages extends AggregateBase
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected static function filterArguments(array $args): array
|
||||
{
|
||||
return array_filter(
|
||||
@@ -210,6 +219,8 @@ class Averages extends AggregateBase
|
||||
/**
|
||||
* Special variant of array_count_values that isn't limited to strings and integers,
|
||||
* but can work with floating point numbers as values.
|
||||
*
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
private static function modeCalc(array $data): float|string
|
||||
{
|
||||
@@ -219,9 +230,11 @@ class Averages extends AggregateBase
|
||||
$maxfreqkey = '';
|
||||
$maxfreqdatum = '';
|
||||
foreach ($data as $datum) {
|
||||
/** @var float|string $datum */
|
||||
$found = false;
|
||||
++$index;
|
||||
foreach ($frequencyArray as $key => $value) {
|
||||
/** @var string[] $value */
|
||||
if ((string) $value['value'] == (string) $datum) {
|
||||
++$frequencyArray[$key]['frequency'];
|
||||
$freq = $frequencyArray[$key]['frequency'];
|
||||
|
||||
@@ -9,6 +9,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Database\DMin;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Database\DSum;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcException;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
|
||||
|
||||
class Conditional
|
||||
{
|
||||
@@ -24,16 +25,22 @@ class Conditional
|
||||
* Excel Function:
|
||||
* AVERAGEIF(range,condition[, average_range])
|
||||
*
|
||||
* @param mixed $range Data values
|
||||
* @param null|array|string $condition the criteria that defines which cells will be checked
|
||||
* @param mixed $range Data values, expect array
|
||||
* @param null|mixed[]|string $condition the criteria that defines which cells will be checked
|
||||
* @param mixed $averageRange Data values
|
||||
*/
|
||||
public static function AVERAGEIF(mixed $range, null|array|string $condition, mixed $averageRange = []): null|int|float|string
|
||||
{
|
||||
if (!is_array($range) || !is_array($averageRange) || array_key_exists(0, $range) || array_key_exists(0, $averageRange)) {
|
||||
$refError = ExcelError::REF();
|
||||
if (in_array($refError, [$range, $averageRange], true)) {
|
||||
return $refError;
|
||||
}
|
||||
|
||||
throw new CalcException('Must specify range of cells, not any kind of literal');
|
||||
}
|
||||
$database = self::databaseFromRangeAndValue($range, $averageRange);
|
||||
$condition = Functions::flattenSingleValue($condition);
|
||||
$condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]];
|
||||
|
||||
return DAverage::evaluate($database, self::VALUE_COLUMN_NAME, $condition);
|
||||
@@ -53,8 +60,9 @@ class Conditional
|
||||
{
|
||||
if (empty($args)) {
|
||||
return 0.0;
|
||||
} elseif (count($args) === 3) {
|
||||
return self::AVERAGEIF($args[1], $args[2], $args[0]);
|
||||
}
|
||||
if (count($args) === 3) {
|
||||
return self::AVERAGEIF($args[1], $args[2], $args[0]); //* @phpstan-ignore-line
|
||||
}
|
||||
foreach ($args as $arg) {
|
||||
if (is_array($arg) && array_key_exists(0, $arg)) {
|
||||
@@ -76,11 +84,21 @@ class Conditional
|
||||
* Excel Function:
|
||||
* COUNTIF(range,condition)
|
||||
*
|
||||
* @param mixed[] $range Data values
|
||||
* @param null|array|string $condition the criteria that defines which cells will be counted
|
||||
* @param mixed $range Data values, expect array
|
||||
* @param null|mixed[]|string $condition the criteria that defines which cells will be counted
|
||||
*/
|
||||
public static function COUNTIF(array $range, null|array|string $condition): string|int
|
||||
public static function COUNTIF(mixed $range, null|array|string $condition): string|int
|
||||
{
|
||||
if (
|
||||
!is_array($range)
|
||||
|| array_key_exists(0, $range)
|
||||
) {
|
||||
if ($range === ExcelError::REF()) {
|
||||
return $range;
|
||||
}
|
||||
|
||||
throw new CalcException('Must specify range of cells, not any kind of literal');
|
||||
}
|
||||
// Filter out any empty values that shouldn't be included in a COUNT
|
||||
$range = array_filter(
|
||||
Functions::flattenArray($range),
|
||||
@@ -88,6 +106,7 @@ class Conditional
|
||||
);
|
||||
|
||||
$range = array_merge([[self::CONDITION_COLUMN_NAME]], array_chunk($range, 1));
|
||||
$condition = Functions::flattenSingleValue($condition);
|
||||
$condition = array_merge([[self::CONDITION_COLUMN_NAME]], [[$condition]]);
|
||||
|
||||
return DCount::evaluate($range, null, $condition, false);
|
||||
@@ -169,11 +188,26 @@ class Conditional
|
||||
* Excel Function:
|
||||
* SUMIF(range, criteria, [sum_range])
|
||||
*
|
||||
* @param array $range Data values
|
||||
* @param mixed $range Data values, expecting array
|
||||
* @param mixed $sumRange Data values, expecting array
|
||||
*/
|
||||
public static function SUMIF(array $range, mixed $condition, array $sumRange = []): null|float|string
|
||||
public static function SUMIF(mixed $range, mixed $condition, mixed $sumRange = []): null|float|string
|
||||
{
|
||||
if (
|
||||
!is_array($range)
|
||||
|| array_key_exists(0, $range)
|
||||
|| !is_array($sumRange)
|
||||
|| array_key_exists(0, $sumRange)
|
||||
) {
|
||||
$refError = ExcelError::REF();
|
||||
if (in_array($refError, [$range, $sumRange], true)) {
|
||||
return $refError;
|
||||
}
|
||||
|
||||
throw new CalcException('Must specify range of cells, not any kind of literal');
|
||||
}
|
||||
$database = self::databaseFromRangeAndValue($range, $sumRange);
|
||||
$condition = Functions::flattenSingleValue($condition);
|
||||
$condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]];
|
||||
|
||||
return DSum::evaluate($database, self::VALUE_COLUMN_NAME, $condition);
|
||||
@@ -203,7 +237,11 @@ class Conditional
|
||||
return DSum::evaluate($database, self::VALUE_COLUMN_NAME, $conditions);
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[][]
|
||||
*/
|
||||
private static function buildConditionSet(...$args): array
|
||||
{
|
||||
$conditions = self::buildConditions(1, ...$args);
|
||||
@@ -211,7 +249,11 @@ class Conditional
|
||||
return array_map(null, ...$conditions);
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[][]
|
||||
*/
|
||||
private static function buildConditionSetForValueRange(...$args): array
|
||||
{
|
||||
$conditions = self::buildConditions(2, ...$args);
|
||||
@@ -226,7 +268,11 @@ class Conditional
|
||||
return array_map(null, ...$conditions);
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[][]
|
||||
*/
|
||||
private static function buildConditions(int $startOffset, ...$args): array
|
||||
{
|
||||
$conditions = [];
|
||||
@@ -241,7 +287,11 @@ class Conditional
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private static function buildDatabase(...$args): array
|
||||
{
|
||||
$database = [];
|
||||
@@ -249,7 +299,11 @@ class Conditional
|
||||
return self::buildDataSet(0, $database, ...$args);
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private static function buildDatabaseWithValueRange(...$args): array
|
||||
{
|
||||
$database = [];
|
||||
@@ -261,7 +315,12 @@ class Conditional
|
||||
return self::buildDataSet(1, $database, ...$args);
|
||||
}
|
||||
|
||||
/** @param array $args */
|
||||
/**
|
||||
* @param mixed[][] $database
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private static function buildDataSet(int $startOffset, array $database, ...$args): array
|
||||
{
|
||||
$pairCount = 1;
|
||||
@@ -277,6 +336,12 @@ class Conditional
|
||||
return array_map(null, ...$database);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $range
|
||||
* @param mixed[] $valueRange
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private static function databaseFromRangeAndValue(array $range, array $valueRange = []): array
|
||||
{
|
||||
$range = Functions::flattenArray($range);
|
||||
|
||||
@@ -23,7 +23,7 @@ class Confidence
|
||||
* @param mixed $size As an integer
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function CONFIDENCE(mixed $alpha, mixed $stdDev, mixed $size)
|
||||
@@ -46,6 +46,9 @@ class Confidence
|
||||
/** @var float $temp */
|
||||
$temp = Distributions\StandardNormal::inverse(1 - $alpha / 2);
|
||||
|
||||
return Functions::scalar($temp * $stdDev / sqrt($size));
|
||||
/** @var float */
|
||||
$result = Functions::scalar($temp * $stdDev / sqrt($size));
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class Deviations
|
||||
* kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a
|
||||
* relatively flat distribution.
|
||||
*
|
||||
* @param array ...$args Data Series
|
||||
* @param mixed[] ...$args Data Series
|
||||
*/
|
||||
public static function kurtosis(...$args): string|int|float
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class Deviations
|
||||
* asymmetric tail extending toward more positive values. Negative skewness indicates a
|
||||
* distribution with an asymmetric tail extending toward more negative values.
|
||||
*
|
||||
* @param array ...$args Data Series
|
||||
* @param mixed[] ...$args Data Series
|
||||
*
|
||||
* @return float|int|string The result, or a string containing an error
|
||||
*/
|
||||
@@ -122,7 +122,7 @@ class Deviations
|
||||
return ExcelError::VALUE();
|
||||
} else {
|
||||
// Is it a numeric value?
|
||||
if ((is_numeric($arg)) && (!is_string($arg))) {
|
||||
if (!is_string($arg)) {
|
||||
$summer += (($arg - $mean) / $stdDev) ** 3;
|
||||
++$count;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class Beta
|
||||
* @param mixed $rMax as an float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value, mixed $alpha, mixed $beta, mixed $rMin = 0.0, mixed $rMax = 1.0): array|string|float
|
||||
@@ -86,7 +86,7 @@ class Beta
|
||||
* @param mixed $rMax Maximum value as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverse(mixed $probability, mixed $alpha, mixed $beta, mixed $rMin = 0.0, mixed $rMax = 1.0): array|string|float
|
||||
|
||||
@@ -30,7 +30,7 @@ class Binomial
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value, mixed $trials, mixed $probability, mixed $cumulative)
|
||||
@@ -78,7 +78,7 @@ class Binomial
|
||||
* If null, then this will indicate the same as the number of Successes
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function range(mixed $trials, mixed $probability, mixed $successes, mixed $limit = null): array|string|float|int
|
||||
@@ -132,7 +132,7 @@ class Binomial
|
||||
* @param mixed $probability Probability of success on each trial as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*
|
||||
@@ -181,7 +181,7 @@ class Binomial
|
||||
* @param mixed $alpha criterion value as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverse(mixed $trials, mixed $probability, mixed $alpha): array|string|int
|
||||
|
||||
@@ -23,7 +23,7 @@ class ChiSquared
|
||||
* @param mixed $degrees Integer degrees of freedom
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distributionRightTail(mixed $value, mixed $degrees): array|string|int|float
|
||||
@@ -65,7 +65,7 @@ class ChiSquared
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|int|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distributionLeftTail(mixed $value, mixed $degrees, mixed $cumulative): array|string|int|float
|
||||
@@ -113,7 +113,7 @@ class ChiSquared
|
||||
* @param mixed $degrees Integer degrees of freedom
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverseRightTail(mixed $probability, mixed $degrees)
|
||||
@@ -133,10 +133,8 @@ class ChiSquared
|
||||
return ExcelError::NAN();
|
||||
}
|
||||
|
||||
$callback = function ($value) use ($degrees): float {
|
||||
return 1 - (Gamma::incompleteGamma($degrees / 2, $value / 2)
|
||||
$callback = fn (float $value): float => 1 - (Gamma::incompleteGamma($degrees / 2, $value / 2)
|
||||
/ Gamma::gammaValue($degrees / 2));
|
||||
};
|
||||
|
||||
$newtonRaphson = new NewtonRaphson($callback);
|
||||
|
||||
@@ -153,7 +151,7 @@ class ChiSquared
|
||||
* @param mixed $degrees Integer degrees of freedom
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverseLeftTail(mixed $probability, mixed $degrees): array|string|float
|
||||
@@ -183,13 +181,15 @@ class ChiSquared
|
||||
* (of observed and expected frequencies), are likely to be simply due to sampling error,
|
||||
* or if they are likely to be real.
|
||||
*
|
||||
* @param mixed $actual an array of observed frequencies
|
||||
* @param mixed $expected an array of expected frequencies
|
||||
* @param float[] $actual an array of observed frequencies
|
||||
* @param float[] $expected an array of expected frequencies
|
||||
*/
|
||||
public static function test(mixed $actual, mixed $expected): float|string
|
||||
public static function test($actual, $expected): float|string
|
||||
{
|
||||
$rows = count($actual);
|
||||
/** @var float[] */
|
||||
$actual = Functions::flattenArray($actual);
|
||||
/** @var float[] */
|
||||
$expected = Functions::flattenArray($expected);
|
||||
$columns = intdiv(count($actual), $rows);
|
||||
|
||||
@@ -211,6 +211,7 @@ class ChiSquared
|
||||
|
||||
$degrees = self::degrees($rows, $columns);
|
||||
|
||||
/** @var float|string */
|
||||
$result = Functions::scalar(self::distributionRightTail($result, $degrees));
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -24,7 +24,7 @@ class Exponential
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value, mixed $lambda, mixed $cumulative): array|string|float
|
||||
|
||||
@@ -27,7 +27,7 @@ class F
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value, mixed $u, mixed $v, mixed $cumulative): array|string|float
|
||||
|
||||
@@ -20,7 +20,7 @@ class Fisher
|
||||
* @param mixed $value Float value for which we want the probability
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value): array|string|float
|
||||
@@ -30,7 +30,7 @@ class Fisher
|
||||
}
|
||||
|
||||
try {
|
||||
DistributionValidations::validateFloat($value);
|
||||
$value = DistributionValidations::validateFloat($value);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Fisher
|
||||
* @param mixed $probability Float probability at which you want to evaluate the distribution
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverse(mixed $probability): array|string|float
|
||||
@@ -62,7 +62,7 @@ class Fisher
|
||||
}
|
||||
|
||||
try {
|
||||
DistributionValidations::validateFloat($probability);
|
||||
$probability = DistributionValidations::validateFloat($probability);
|
||||
} catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class Gamma extends GammaBase
|
||||
* @param mixed $value Float value for which we want the probability
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -55,7 +55,7 @@ class Gamma extends GammaBase
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $value, mixed $a, mixed $b, mixed $cumulative)
|
||||
@@ -92,7 +92,7 @@ class Gamma extends GammaBase
|
||||
* @param mixed $beta Parameter to the distribution as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function inverse(mixed $probability, mixed $alpha, mixed $beta)
|
||||
@@ -124,7 +124,7 @@ class Gamma extends GammaBase
|
||||
* @param mixed $value Float Value at which you want to evaluate the distribution
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function ln(mixed $value): array|string|float
|
||||
|
||||
@@ -39,9 +39,6 @@ abstract class GammaBase
|
||||
while ((abs($dx) > Functions::PRECISION) && (++$i <= self::MAX_ITERATIONS)) {
|
||||
// Apply Newton-Raphson step
|
||||
$result = self::calculateDistribution($x, $alpha, $beta, true);
|
||||
if (!is_float($result)) {
|
||||
return ExcelError::NA();
|
||||
}
|
||||
$error = $result - $probability;
|
||||
|
||||
if ($error == 0.0) {
|
||||
@@ -54,9 +51,6 @@ abstract class GammaBase
|
||||
|
||||
$pdf = self::calculateDistribution($x, $alpha, $beta, false);
|
||||
// Avoid division by zero
|
||||
if (!is_float($pdf)) {
|
||||
return ExcelError::NA();
|
||||
}
|
||||
if ($pdf !== 0.0) {
|
||||
$dx = $error / $pdf;
|
||||
$xNew = $x - $dx;
|
||||
@@ -97,6 +91,16 @@ abstract class GammaBase
|
||||
return $x ** $a * exp(0 - $x) * $summer;
|
||||
}
|
||||
|
||||
private const GAMMA_VALUE_P0 = 1.000000000190015;
|
||||
private const GAMMA_VALUE_P = [
|
||||
1 => 76.18009172947146,
|
||||
2 => -86.50532032941677,
|
||||
3 => 24.01409824083091,
|
||||
4 => -1.231739572450155,
|
||||
5 => 1.208650973866179e-3,
|
||||
6 => -5.395239384953e-6,
|
||||
];
|
||||
|
||||
//
|
||||
// Implementation of the Gamma function
|
||||
//
|
||||
@@ -106,23 +110,13 @@ abstract class GammaBase
|
||||
return 0;
|
||||
}
|
||||
|
||||
static $p0 = 1.000000000190015;
|
||||
static $p = [
|
||||
1 => 76.18009172947146,
|
||||
2 => -86.50532032941677,
|
||||
3 => 24.01409824083091,
|
||||
4 => -1.231739572450155,
|
||||
5 => 1.208650973866179e-3,
|
||||
6 => -5.395239384953e-6,
|
||||
];
|
||||
|
||||
$y = $x = $value;
|
||||
$tmp = $x + 5.5;
|
||||
$tmp -= ($x + 0.5) * log($tmp);
|
||||
|
||||
$summer = $p0;
|
||||
$summer = self::GAMMA_VALUE_P0;
|
||||
for ($j = 1; $j <= 6; ++$j) {
|
||||
$summer += ($p[$j] / ++$y);
|
||||
$summer += (self::GAMMA_VALUE_P[$j] / ++$y);
|
||||
}
|
||||
|
||||
return exp(0 - $tmp + log(self::SQRT2PI * $summer / $x));
|
||||
|
||||
@@ -26,7 +26,7 @@ class HyperGeometric
|
||||
* @param mixed $populationNumber Integer population size
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function distribution(mixed $sampleSuccesses, mixed $sampleNumber, mixed $populationSuccesses, mixed $populationNumber): array|string|float
|
||||
|
||||
@@ -23,7 +23,7 @@ class LogNormal
|
||||
* @param mixed $stdDev Standard Deviation as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ class LogNormal
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -106,7 +106,7 @@ class LogNormal
|
||||
* @param mixed $stdDev Standard Deviation as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*
|
||||
|
||||
@@ -9,9 +9,10 @@ class NewtonRaphson
|
||||
{
|
||||
private const MAX_ITERATIONS = 256;
|
||||
|
||||
/** @var callable */
|
||||
/** @var callable(float): mixed */
|
||||
protected $callback;
|
||||
|
||||
/** @param callable(float): mixed $callback */
|
||||
public function __construct(callable $callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
@@ -29,6 +30,9 @@ class NewtonRaphson
|
||||
while ((abs($dx) > Functions::PRECISION) && ($i++ < self::MAX_ITERATIONS)) {
|
||||
// Apply Newton-Raphson step
|
||||
$result = call_user_func($this->callback, $x);
|
||||
if (!is_float($result)) {
|
||||
return ExcelError::VALUE();
|
||||
}
|
||||
$error = $result - $probability;
|
||||
|
||||
if ($error == 0.0) {
|
||||
|
||||
@@ -29,7 +29,7 @@ class Normal
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ class Normal
|
||||
* @param mixed $stdDev Standard Deviation as a float
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -119,6 +119,7 @@ class Normal
|
||||
// Input paramater is $p - probability - where 0 < p < 1.
|
||||
|
||||
// Coefficients in rational approximations
|
||||
/** @var array<int, float> */
|
||||
static $a = [
|
||||
1 => -3.969683028665376e+01,
|
||||
2 => 2.209460984245205e+02,
|
||||
@@ -128,6 +129,7 @@ class Normal
|
||||
6 => 2.506628277459239e+00,
|
||||
];
|
||||
|
||||
/** @var array<int, float> */
|
||||
static $b = [
|
||||
1 => -5.447609879822406e+01,
|
||||
2 => 1.615858368580409e+02,
|
||||
@@ -136,6 +138,7 @@ class Normal
|
||||
5 => -1.328068155288572e+01,
|
||||
];
|
||||
|
||||
/** @var array<int, float> */
|
||||
static $c = [
|
||||
1 => -7.784894002430293e-03,
|
||||
2 => -3.223964580411365e-01,
|
||||
@@ -145,6 +148,7 @@ class Normal
|
||||
6 => 2.938163982698783e+00,
|
||||
];
|
||||
|
||||
/** @var array<int, float> */
|
||||
static $d = [
|
||||
1 => 7.784695709041462e-03,
|
||||
2 => 3.224671290700398e-01,
|
||||
|
||||
@@ -25,7 +25,7 @@ class Poisson
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,7 @@ class StandardNormal
|
||||
* @param mixed $value Float value for which we want the probability
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -51,7 +51,7 @@ class StandardNormal
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ class StandardNormal
|
||||
* handled by the logic in Normal::inverse()
|
||||
* All we need to do is pass the value through as scalar or as array
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ class StandardNormal
|
||||
*
|
||||
* @param mixed $value Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ class StandardNormal
|
||||
* if null, we use the standard deviation of the dataset
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string (string if result is an error)
|
||||
* @return array<mixed>|float|string (string if result is an error)
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ class StudentT
|
||||
* @param mixed $tails Integer value for the number of tails (1 or 2)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ class StudentT
|
||||
* @param mixed $degrees Integer value for degrees of freedom
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string The result, or a string containing an error
|
||||
* @return array<mixed>|float|string The result, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ class Weibull
|
||||
* @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false)
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string (string if result is an error)
|
||||
* @return array<mixed>|float|string (string if result is an error)
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,7 @@ class Maximum extends MaxMinBase
|
||||
if ($returnValue === null) {
|
||||
return 0;
|
||||
}
|
||||
/** @var float|int|string $returnValue */
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ class Maximum extends MaxMinBase
|
||||
if ($returnValue === null) {
|
||||
return 0;
|
||||
}
|
||||
/** @var float|int|string $returnValue */
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ class Minimum extends MaxMinBase
|
||||
if ($returnValue === null) {
|
||||
return 0;
|
||||
}
|
||||
/** @var float|int|string $returnValue */
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ class Minimum extends MaxMinBase
|
||||
if ($returnValue === null) {
|
||||
return 0;
|
||||
}
|
||||
/** @var float|int|string $returnValue */
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
@@ -45,11 +45,13 @@ class Percentiles
|
||||
$mValueCount = count($mArgs);
|
||||
if ($mValueCount > 0) {
|
||||
sort($mArgs);
|
||||
/** @var float[] $mArgs */
|
||||
$count = Counts::COUNT($mArgs);
|
||||
$index = $entry * ($count - 1);
|
||||
$iBase = floor($index);
|
||||
if ($index == $iBase) {
|
||||
return $mArgs[$index];
|
||||
$indexFloor = floor($index);
|
||||
$iBase = (int) $indexFloor;
|
||||
if ($index == $indexFloor) {
|
||||
return $mArgs[$iBase];
|
||||
}
|
||||
$iNext = $iBase + 1;
|
||||
$iProportion = $index - $iBase;
|
||||
@@ -101,6 +103,7 @@ class Percentiles
|
||||
|
||||
$pos = array_search($value, $valueSet);
|
||||
if ($pos === false) {
|
||||
/** @var float[] $valueSet */
|
||||
$pos = 0;
|
||||
$testValue = $valueSet[0];
|
||||
while ($testValue < $value) {
|
||||
@@ -184,6 +187,11 @@ class Percentiles
|
||||
return ++$pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $dataSet
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected static function percentileFilterValues(array $dataSet): array
|
||||
{
|
||||
return array_filter(
|
||||
@@ -192,6 +200,11 @@ class Percentiles
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $dataSet
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected static function rankFilterValues(array $dataSet): array
|
||||
{
|
||||
return array_filter(
|
||||
|
||||
@@ -26,7 +26,7 @@ class Permutations
|
||||
* @param mixed $numInSet Integer number of objects in each permutation
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string Number of permutations, or a string containing an error
|
||||
* @return array<mixed>|float|int|string Number of permutations, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
@@ -72,7 +72,7 @@ class Permutations
|
||||
* @param mixed $numInSet Integer number of objects in each permutation
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|int|string Number of permutations, or a string containing an error
|
||||
* @return array<mixed>|float|int|string Number of permutations, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@ class Size
|
||||
return ExcelError::NAN();
|
||||
}
|
||||
rsort($mArgs);
|
||||
/** @var float[] $mArgs */
|
||||
|
||||
return $mArgs[$entry];
|
||||
}
|
||||
@@ -71,6 +72,7 @@ class Size
|
||||
return ExcelError::NAN();
|
||||
}
|
||||
sort($mArgs);
|
||||
/** @var float[] $mArgs */
|
||||
|
||||
return $mArgs[$entry];
|
||||
}
|
||||
@@ -80,6 +82,8 @@ class Size
|
||||
|
||||
/**
|
||||
* @param mixed[] $args Data values
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected static function filter(array $args): array
|
||||
{
|
||||
|
||||
@@ -15,14 +15,14 @@ class Standardize extends StatisticalValidations
|
||||
*
|
||||
* Returns a normalized value from a distribution characterized by mean and standard_dev.
|
||||
*
|
||||
* @param array|float $value Value to normalize
|
||||
* @param array<mixed>|float $value Value to normalize
|
||||
* Or can be an array of values
|
||||
* @param array|float $mean Mean Value
|
||||
* @param array<mixed>|float $mean Mean Value
|
||||
* Or can be an array of values
|
||||
* @param array|float $stdDev Standard Deviation
|
||||
* @param array<mixed>|float $stdDev Standard Deviation
|
||||
* Or can be an array of values
|
||||
*
|
||||
* @return array|float|string Standardized value, or a string containing an error
|
||||
* @return array<mixed>|float|string Standardized value, or a string containing an error
|
||||
* If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
|
||||
@@ -12,6 +12,10 @@ class Trends
|
||||
{
|
||||
use ArrayEnabled;
|
||||
|
||||
/**
|
||||
* @param array<mixed> $array1
|
||||
* @param array<mixed> $array2
|
||||
*/
|
||||
private static function filterTrendValues(array &$array1, array &$array2): void
|
||||
{
|
||||
foreach ($array1 as $key => $value) {
|
||||
@@ -24,6 +28,9 @@ class Trends
|
||||
/**
|
||||
* @param mixed $array1 should be array, but scalar is made into one
|
||||
* @param mixed $array2 should be array, but scalar is made into one
|
||||
*
|
||||
* @param-out array<mixed> $array1
|
||||
* @param-out array<mixed> $array2
|
||||
*/
|
||||
private static function checkTrendArrays(mixed &$array1, mixed &$array2): void
|
||||
{
|
||||
@@ -45,6 +52,10 @@ class Trends
|
||||
$array2 = array_merge($array2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $yValues
|
||||
* @param mixed[] $xValues
|
||||
*/
|
||||
protected static function validateTrendArrays(array $yValues, array $xValues): void
|
||||
{
|
||||
$yValueCount = count($yValues);
|
||||
@@ -116,7 +127,7 @@ class Trends
|
||||
* @param mixed[] $yValues array of mixed Data Series Y
|
||||
* @param mixed[] $xValues array of mixed Data Series X
|
||||
*
|
||||
* @return array|bool|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* @return array<mixed>|bool|float|string If an array of numbers is passed as an argument, then the returned result will also be an array
|
||||
* with the same dimensions
|
||||
*/
|
||||
public static function FORECAST(mixed $xValue, array $yValues, array $xValues)
|
||||
@@ -164,6 +175,7 @@ class Trends
|
||||
|
||||
$returnArray = [];
|
||||
foreach ($newValues as $xValue) {
|
||||
/** @var float $xValue */
|
||||
$returnArray[0][] = [$bestFitExponential->getValueOfYForX($xValue)];
|
||||
}
|
||||
|
||||
@@ -203,7 +215,7 @@ class Trends
|
||||
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
|
||||
* @param mixed $stats A logical (boolean) value specifying whether to return additional regression statistics
|
||||
*
|
||||
* @return array|string The result, or a string containing an error
|
||||
* @return array<mixed>|string The result, or a string containing an error
|
||||
*/
|
||||
public static function LINEST(array $yValues, ?array $xValues = null, mixed $const = true, mixed $stats = false): string|array
|
||||
{
|
||||
@@ -264,7 +276,7 @@ class Trends
|
||||
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
|
||||
* @param mixed $stats A logical (boolean) value specifying whether to return additional regression statistics
|
||||
*
|
||||
* @return array|string The result, or a string containing an error
|
||||
* @return array<mixed>|string The result, or a string containing an error
|
||||
*/
|
||||
public static function LOGEST(array $yValues, ?array $xValues = null, mixed $const = true, mixed $stats = false): string|array
|
||||
{
|
||||
@@ -417,6 +429,7 @@ class Trends
|
||||
|
||||
$returnArray = [];
|
||||
foreach ($newValues as $xValue) {
|
||||
/** @var float $xValue */
|
||||
$returnArray[0][] = [$bestFitLinear->getValueOfYForX($xValue)];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user