[Numpy-discussion] Fitting a curve on a log-normal distributed data
Gökhan Sever
gokhansever@gmail....
Tue Nov 17 11:29:10 CST 2009
On Tue, Nov 17, 2009 at 12:13 AM, Ian Mallett <geometrian@gmail.com> wrote:
> Theory wise:
> -Do a linear regression on your data.
> -Apply a logrithmic transform to your data's dependent variable, and do
> another linear regression.
> -Apply a logrithmic transform to your data's independent variable, and do
> another linear regression.
> -Take the best regression (highest r^2 value) and execute a back transform.
>
> Then, to get your desired extrapolation, simply substitute in the size for
> the independent variable to get the expected value.
>
> If, however, you're looking for how to implement this in NumPy or SciPy, I
> can't really help :-P
> Ian
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
OK, before applying your suggestions. I have a few more questions. Here is 1
real-sample data that I will use as a part of the log-normal fitting. There
is 15 elements in this arrays each being a concentration for corresponding
0.1 - 3.0 um size ranges.
I[74]: conc
O[74]:
array([ 119.7681, 118.546 , 146.6548, 96.5478, 109.9911, 32.9974,
20.7762, 6.1107, 12.2212, 3.6664, 3.6664, 1.2221,
2.4443, 2.4443, 3.6664])
For now not calibrated size range I just assume a linear array:
I[78]: sizes = linspace(0.1, 3.0, 15)
I[79]: sizes
O[79]:
array([ 0.1 , 0.30714286, 0.51428571, 0.72142857, 0.92857143,
1.13571429, 1.34285714, 1.55 , 1.75714286, 1.96428571,
2.17142857, 2.37857143, 2.58571429, 2.79285714, 3. ])
Not a very ideal looking log-normal, but so far I don't know what else
besides a log-normal fit would give me a better estimate:
I[80]: figure(); plot(sizes, conc)
http://img406.imageshack.us/img406/156/sizeconc.png
scipy.stats has the lognorm.fit
lognorm.fit(data,s,loc=0,scale=1)
- Parameter estimates for lognorm data
and applying this to my data. However not sure the right way of calling it,
and not sure if this could be applied to my case?
I[81]: stats.lognorm.fit(conc)
O[81]: array([ 2.31386066, 1.19126064, 9.5748391 ])
Lastly, what is the way to create a ideal log-normal sample using the
stats.lognorm.rvs?
Thanks
--
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091117/216ea12b/attachment.html
More information about the NumPy-Discussion
mailing list