komrane Posted November 28, 2008 Posted November 28, 2008 Hi everyone, I want to find a function to fit a two arrays data (X,Y=f(X)) with high precision, but I am not succeed. Can any one help me. These are my data: X={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 ,20,21,22,23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49 ,50,51,52,53,54,55,56,57,58,59,60,61, 62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78 ,79,80,81,82,83,84,85,86,87,88,89,90, 91,92,93,94,95,96,97,98,99,100,101,102,103}; Y={-3.82047923,-4.78741509,-3.7235349,-3.83978508,-4.05577459,-4.30089612,-4.533835, -4.74829898,-4.94488133,-5.12552735,-4.85195336,-4.7612524,-4.68355948,-4.69161082, -4.73528276,-4.79596239,-4.86512986,-4.93839307,-4.76858464,-4.6914727,-4.75906268, -4.83409367,-4.91083489,-5.06679286,-5.06287703,-5.13691706,-5.20911926,-5.27953551, -5.41696518,-5.38100772,-5.41533957,-5.37176179,-5.37544389,-5.38749604,-5.40564269, -5.42796115,-5.31359172,-5.24494792,-5.24966838,-5.26982538,-5.33876087,-5.36920739, -5.40155805,-5.43522901,-5.47070746,-5.55225881,-5.54130792,-5.53404017,-5.50585981, -5.49365225,-5.48926542,-5.4907033,-5.49650191,-5.50562495,-5.42179559,-5.36756524, -5.36483956,-5.43302415,-5.46809702,-5.5035703,-5.53917246,-5.57474765,-5.61100546, -5.61535429,-5.6811938,-5.71600271,-5.75053965,-5.78479005,-5.81874653,-5.85240181, -5.8537986,-5.86366491,-5.87645036,-5.89129497,-5.90794966,-5.92512355,-5.94314335, -5.98374099,-6.00311053,-6.00091604,-5.97752754,-5.96422759,-5.95638692,-5.9523968, -5.95137799,-5.95274728,-5.89262269,-5.85051099,-5.83581257,-5.83046564,-5.86806419, -5.88735021,-5.90739448,-5.95040446,-5.97217823,-5.97055505,-5.99290744,-6.03952233, -6.06244391,-6.08579093,-6.10898718,-6.1322644,-6.12755437}. Thanks a lot in advance
timo Posted November 28, 2008 Posted November 28, 2008 One of the most important aspects of fitting functions is realizing that "I want to fit a function through a number of points" is not a sufficient statement for a unique solution to exist (or make sense). You have to specify what kind of function (ideally described by a small amount of free parameters that then shall be fitted) you want to fit to the data.
Bignose Posted November 28, 2008 Posted November 28, 2008 Atheist makes a good point. You can find a 104th degree polynomial that will fit all of your data exactly, but you probably don't really want a 104th degree polynomial fit because in between the points is probably going to be very poor. Does the physics of situation give you any insight into what kind of curve it may be? Exponential? Logarithmic? Linear? Quadratic? Once you have a decent candidate function or two, then the easiest and most often used method is called least squares: http://en.wikipedia.org/wiki/Least_squares Basically, you draw your curve, find the distance between each point from the data and your curve, square that distance (so that you don't have negatives), add up the squares of all those distances between the data and the curve, and minimize the total of all those squares. There are more advanced versions, especially if you have good measures on the confidence of each of your data points, but least squares is a good starting point.
the tree Posted November 28, 2008 Posted November 28, 2008 Having some idea of what type of curve you're looking for is pretty handy: it would help to know where the data is coming from. I've attached a scatterplot of the data, in case any experts can recognise the shape at a glance.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now