473,387 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calculating IRR's in Ruby

1
Hi - does anyone know of a good way of calculating an IRR (internal rate of return) from a (variable length) series of cash flows. I need it to be reasonably efficient. I know that it will have to be an iterative solution.
Oct 26 '07 #1
1 4897
bugQ
1
http://pastie.org/144919

I just wrote it this morning in 15 min. or so, using the trial-and-error model. It can find the IRR for 100 cash flows to 9 decimal places in about 23ms on my 17" MacBook Pro.

Note that this algorithm is O(n^2), i.e. doubling the length of the input array will roughly quadruple the computation time.

EDIT: Ack! Wait, don't use this. It only goes up to 100%. IRR can go past that, can't it? Give me a sec...

EDIT2: Okay, it's fine now, and probably a bit faster, too.
Jan 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Idelso Quintero | last post by:
Hi everyone: I am trying to use the IRR function that comes as part of the Financial Library in VB6, but it is returning some weird values. The case i am testing is fairly simple: initial...
1
by: Burton Wilkins | last post by:
What would be the syntax and namespace to be able to call the VB function IRR?
1
by: Muhammad Qasim Choudry via DotNetMonster.com | last post by:
I want to Use IRR Function in C#.Net but cant find it but when i open Vb.Net projetc under Microsoft.VisualBasic.Financial module i can find that function but i want to use it in in C# for...
2
by: tinaw | last post by:
Hi. I have a working APR quotation system that uses Excel, dialog boxes and some basic VB. I would like to streamline the process by transferring the IRR function into VB but I am a complete...
1
by: JHaworth | last post by:
Hi, Please could someone point me in the right direction with a formula I am trying to create which will enable me to calculate a Net IRR for a series of data? My Problem: •My formula in...
8
by: BertDick | last post by:
This is new to me. I'm trying to calculate the IRR from a cash flow statement. My database fields are Fund ID, Capital calls, Distributions,management fees, net asset value and total cash flow. The...
1
by: BertDick | last post by:
I'm trying to use the IRR function in Ms Access using the code below. Function MyIRR(mygroupid, myguess) as double Dim Values(4) as double' an array with 5 elements Dim x dim rs as...
0
by: smlemmon | last post by:
Hi, This is my first post, but have been an avid reader up until to now. Great resource though. Anyway, onto my problem. I need to use the Microsoft.VisualBasic.Financial.IRR procedure in my...
10
by: asmasm1 | last post by:
i am calculating irr and pass listarray created at runtime to irr function and i get error. as i'm new to .net i have to calculate irr textbox2.text specify the no installments textbox1.text...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.