I can't find a way to do a logarithmic regression in matplotlib,
This can be done relatively easily in spread sheets like gnumeric and excel.
Has anyone got a clue how to do it ?
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
when one person suffers from a delusion it is called insanity. When many
people suffer from a delusion it is called religion."
Robert Pirsig, Zen and the Art of Motorcycle Maintenance
From: João Luís Silva <jsilva@fc...> - 2009-01-06 12:40:38
Oz Nahum wrote:
> I can't find a way to do a logarithmic regression in matplotlib,
> This can be done relatively easily in spread sheets like gnumeric and
> Has anyone got a clue how to do it ?
> Thanks, Oz.
Matplotlib handles the graphics. For numeric regressions and fitting you
should use scipy, such as scipy's least square fit. I don't know if
scipy has a logarithmic regression predefined, but you should be able to
adapt the example below to your needs. This example shows how to fit a
gaussian to some noisy data.
import numpy as np
import numpy.random as random
from scipy.optimize.minpack import leastsq
import pylab as pl
x = np.arange(-5.0,5.0,0.1)
y = 100.0*np.exp(-x**2/25.0)+ 10.0*(random.random(len(x))-0.5)
ls = leastsq(resid,[1.0,1.0],args=(y,x))
y_fit = ls*np.exp(-x**2/ls**2)