|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.poi.ss.formula.functions.Irr
public final class Irr
Calculates the internal rate of return. Syntax is IRR(values) or IRR(values,guess)
Constructor Summary | |
---|---|
Irr()
|
Method Summary | |
---|---|
ValueEval |
evaluate(ValueEval[] args,
int srcRowIndex,
int srcColumnIndex)
|
static double |
irr(double[] income)
Computes the internal rate of return using an estimated irr of 10 percent. |
static double |
irr(double[] values,
double guess)
Calculates IRR using the Newton-Raphson Method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Irr()
Method Detail |
---|
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex)
evaluate
in interface Function
args
- the evaluated function arguments. Empty values are represented with
BlankEval
or MissingArgEval
, never null
.srcRowIndex
- row index of the cell containing the formula under evaluationsrcColumnIndex
- column index of the cell containing the formula under evaluation
ErrorEval
, never null
.
Note - Excel uses the error code #NUM! instead of IEEE NaN, so when
numeric functions evaluate to Double.NaN
be sure to translate the result to ErrorEval.NUM_ERROR
.public static double irr(double[] income)
income
- the income values.
public static double irr(double[] values, double guess)
Starting with the guess, the method cycles through the calculation until the result is accurate within 0.00001 percent. If IRR can't find a result that works after 20 tries, the Double.NaN<> is returned.
The implementation is inspired by the NewtonSolver from the Apache Commons-Math library,
values
- the income values.guess
- the initial guess of irr.
Double.NaN
if the maximum iteration count is exceeded
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |