Hi, I just happened to do the same thing two days ago. If you want uncertainties as well, here is some code that uses scipy.optimize. I just put up a preliminary example on the scipy wiki:
http://www.scipy.org/Cookbook/FittingData?action=show Not the cleanest or most sophisticated code in the world, but it works for simple things. Cheers, Jessica On Dec 6, 2007, at 8:06 AM, Ryan May wrote: > Ping Yeh wrote: >> Hi, >> >> I have (x,y) data that I want to fit to the formula >> y = a * x^b >> to determine a and b. How can I do it? The current >> manual only lists linear fit and polynomial fit. >> > > If you just want quick power law fit without turning to the other > solutions, you can just transform your variables to make it a > linear fit > problem: > > log(y) = log(a * x^b) = log(a) + b * log(x) > > So just do the linear regression with the logarithms of x and y, > and the > slope you get back will be b, and the intercept will be log(a). > > Ryan > > -- > Ryan May > Graduate Research Assistant > School of Meteorology > University of Oklahoma > > ---------------------------------------------------------------------- > --- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users