44 $f1 = self::presentValue($x1,
$values);
45 $f2 = self::presentValue($x2,
$values);
46 for (
$i = 0;
$i < self::FINANCIAL_MAX_ITERATIONS; ++
$i) {
47 if (($f1 * $f2) < 0.0) {
50 if (abs($f1) < abs($f2)) {
51 $f1 = self::presentValue($x1 += 1.6 * ($x1 - $x2),
$values);
53 $f2 = self::presentValue($x2 += 1.6 * ($x2 - $x1),
$values);
56 if (($f1 * $f2) > 0.0) {
69 for (
$i = 0;
$i < self::FINANCIAL_MAX_ITERATIONS; ++
$i) {
72 $f_mid = self::presentValue($x_mid,
$values);
76 if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) {
111 $rr = 1.0 + $reinvestmentRate;
112 $fr = 1.0 + $financeRate;
114 $npvPos = $npvNeg = 0.0;
117 $npvPos += $v / $rr **
$i;
119 $npvNeg += $v / $fr **
$i;
123 if (($npvNeg === 0.0) || ($npvPos === 0.0) || ($reinvestmentRate <= -1.0)) {
127 $mirr = ((-$npvPos * $rr **
$n)
128 / ($npvNeg * ($rr))) ** (1.0 / (
$n - 1)) - 1.0;
150 $countArgs = count($aArgs);
151 for (
$i = 1;
$i <= $countArgs; ++
$i) {
153 if (is_numeric($aArgs[
$i - 1])) {
154 $returnValue += $aArgs[
$i - 1] / (1 + $rate) **
$i;
static rate($values, $guess=0.1)
IRR.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
const FINANCIAL_PRECISION
const FINANCIAL_MAX_ITERATIONS
static presentValue($rate,... $args)
NPV.
static modifiedRate($values, $financeRate, $reinvestmentRate)
MIRR.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.