Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divergence at IRR values near zero #1

Open
aziadeh opened this issue Oct 23, 2017 · 6 comments · Fixed by #2
Open

Divergence at IRR values near zero #1

aziadeh opened this issue Oct 23, 2017 · 6 comments · Fixed by #2

Comments

@aziadeh
Copy link

aziadeh commented Oct 23, 2017

Hey,

Really like how fast the algorithm is but at IRR values that are supposed to be close to zero, the irr_binary_search calculation diverges, irr_newton seem to find the proper solution as well as numpy.irr.

Here's an example of a list that would return a -1 instead of -.01:
[-13897.515699392789, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, 678.69417667002108, -426.40303828879155]
You've ever ran into such problems?

@erikbern
Copy link
Contributor

interesting – will take a look

@aziadeh
Copy link
Author

aziadeh commented Oct 23, 2017

I have a few more examples if you need them.

@erikbern
Copy link
Contributor

sure – if you can send them over i'll add them as unit tests

@aziadeh
Copy link
Author

aziadeh commented Oct 23, 2017

[-12138.436076306429, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, 576.20775733699475, -528.88945762181788]

[-10351.121144852736, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, 450.71546738230256, -654.38174757651018]

[-15634.416942708685, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, 800.12182531566373, -304.9753896431489]
There's an obvious pattern. I still have more but not sure they'll add much because the structure is more or less the same ! Thanks btw:)

@erikbern erikbern mentioned this issue Oct 31, 2017
@erikbern erikbern reopened this Oct 31, 2017
@erikbern
Copy link
Contributor

I think the problem is your polynomials have two roots, one where you expect it, and then another weird root for some large negative number. let me figure it out later

@erikbern
Copy link
Contributor

Yeah here's the plot of the residual as a function of rate – note that it has two zeroes:

image

Note sure why it doesn't converge to the other zero though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants