Function compute

Source
pub fn compute(payments: &[Payment]) -> Result<f64, InvalidPaymentsError>
Expand description

Calculates the internal rate of return of a series of irregular payments.

It tries to identify the rate of return using Newton’s method with an initial guess of 0.1. If that does not provide a solution, it attempts with guesses from -0.99 to 0.99 in increments of 0.01 and returns NaN if that fails too.

§Errors

This function will return InvalidPaymentsError if both positive and negative payments are not provided.