Solved

numpy/scipy polyfit precision

Posted on 2012-03-18
2
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visualizing tuple values in Python (or generally) 3 86
Python tuples 2 133
Python variable _ manually assigned 9 96
python - find anything after $ question. 9 52
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…
Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

733 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