Solved

numpy/scipy polyfit precision

Posted on 2012-03-18
2
659 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
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" www.python.org " You can also get information on Python scripting language from the above mentioned we…
Here I am using Python IDLE(GUI) to write a simple program and save it, so that we can just execute it in future. Because when we write any program and exit from Python then program that we have written will be lost. So for not losing our program we…
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now