Top Description Fields Constructors Methods
org.apache.poi.ss.formula.functions

public final Class Irr

extends Object
implements Function
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.formula.functions.Function
Imports
org.apache.logging.log4j.LogManager, .Logger, org.apache.poi.ss.formula.eval.ErrorEval, .EvaluationException, .NumberEval, .ValueEval

Calculates the internal rate of return. Syntax is IRR(values) or IRR(values,guess)
See Also
Wikipedia on IRR, Excel IRR

Field Summary

Modifier and TypeField and Description
private static final double
private static final Logger
private static final int

Constructor Summary

AccessConstructor and Description
public
Irr()

Method Summary

Modifier and TypeMethod and Description
public ValueEval
evaluate(final ValueEval[]
the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.
args
,
final int
row index of the cell containing the formula under evaluation
srcRowIndex
,
final int
column index of the cell containing the formula under evaluation
srcColumnIndex
)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

public static double

Returns:

the irr.
irr
(double[]
the income values.
income
)

Computes the internal rate of return using an estimated irr of 10 percent.

public static double

Returns:

the irr value. The method returns Double.NaN if the maximum iteration count is exceeded
irr
(double[]
the income values.
values
,
double
the initial guess of irr.
guess
)

Calculates IRR using the Newton-Raphson Method.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ABSOLUTE_ACCURACYback to summary
private static final double ABSOLUTE_ACCURACY
LOGGERback to summary
private static final Logger LOGGER
MAX_ITERATION_COUNTback to summary
private static final int MAX_ITERATION_COUNT

Constructor Detail

Irrback to summary
public Irr()

Method Detail

evaluateback to summary
public ValueEval evaluate(final ValueEval[] args, final int srcRowIndex, final int srcColumnIndex)

Implements org.apache.poi.ss.formula.functions.Function.evaluate.

Parameters
args:ValueEval[]

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

the evaluated function arguments. Empty values are represented with BlankEval or MissingArgEval, never null.

srcRowIndex:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

row index of the cell containing the formula under evaluation

srcColumnIndex:int

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

column index of the cell containing the formula under evaluation

Returns:ValueEval

Doc from org.apache.poi.ss.formula.functions.Function.evaluate.

The evaluated result, possibly an 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.

irrback to summary
public static double irr(double[] income)

Computes the internal rate of return using an estimated irr of 10 percent.

Parameters
income:double[]

the income values.

Returns:double

the irr.

irrback to summary
public static double irr(double[] values, double guess)

Calculates IRR using the Newton-Raphson Method.

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 1000 tries, the Double.NaN is returned.

The implementation is inspired by the NewtonSolver from the Apache Commons-Math library,

Parameters
values:double[]

the income values.

guess:double

the initial guess of irr.

Returns:double

the irr value. The method returns Double.NaN if the maximum iteration count is exceeded

See Also
http://commons.apache.org, http://en.wikipedia.org/wiki/Internal_rate_of_return#Numerical_solution, http://en.wikipedia.org/wiki/Newton%27s_method