Solved

numpy/scipy polyfit precision

Posted on 2012-03-18
2
664 Views
Last Modified: 2012-03-18
I am trying to use numpy to perform a polyfit on a set of very large integers (~256bits).  The points for the line are generated by randomly assigning coefficients and then picking X values at random.  I then try to use numpy to recreate the polynomial from just those points, but the answer is not exact.  It is usually off by less than 10, but it shouldn't be.  Is there a way to turn up the precision for numpy?  matlab is able to crunch these numbers and come up with the exact polynomial, so I would expect numpy to be able to do the same.
0
Comment
Question by:mattjp88
2 Comments
 
LVL 3

Accepted Solution

by:
defc0n1 earned 500 total points
ID: 37734769
As far as I know numpy does not support higher than double precision (float64).

Maybe mpmath can be useful for you.
They support real and complex numbers with arbitrary precision.

EDIT:

Forgot to mention there is also mlabwrap which gives you all of Matlab`s functionality in python.
0
 
LVL 6

Author Closing Comment

by:mattjp88
ID: 37735658
Thanks for pointing out mpmath, it looks promising.

This was a small piece of a larger project, and fitting a polynomial ended up being only one method to get the answer we needed.  So we switched algorithms, so I wont be able to verify any other answers to this question.

the mention of mpmath and mlabwrap is enough to award points I think.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create users in Active Directory using python? 3 320
how to check case insensitive substring 5 53
How To Loop - Python 19 79
How can I do this in Pyhton? 12 113
Dictionaries contain key:value pairs. Which means a collection of tuples with an attribute name and an assigned value to it. The semicolon present in between each key and values and attribute with values are delimited with a comma.  In python we can…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now