In [1]:
%matplotlib inline
from pylab import*

In [2]:
import os
import numpy as np

In [3]:
from cvfit import data
from cvfit.equations import GHK
from cvfit.fitting import SingleFitSession

In [4]:
filename = "./Example/Example.xlsx"
set0 = data.read_sets_from_Excel(filename, 2, 0, 3)[0]
print("Loaded: " + os.path.split(str(filename))[1])
print (str(set0))


Loaded: Example.xlsx

X	Y	s(Y)	weight
5	-8.42	0	1
5	-7.13	0	1
5	-9.45	0	1
5	-7.01	0	1
50	-5.02	0	1
50	-6.2	0	1
50	-4.96	0	1
100	-2.41	0	1
100	-1.83	0	1
100	-2.16	0	1

Linear equation fit


In [5]:
equation = GHK('GHK', pars=np.array([1.0, 150.0, 145.0, 5.0]))
fsession = SingleFitSession(set0, equation)


	Fitting session for Set 1 initialised!

In [6]:
fsession.fit()
fsession.calculate_errors()
print(fsession.string_estimates())
print(fsession.string_liklimits())


Number of point fitted = 10
Number of parameters estimated = 1
Degrees of freedom = 9
Residual error SD = 0.776      (variance = 0.602)
Parameter 1: r  	= 0.707792  	  Approx SD = 0.0102738	  CV = 1.5
Parameter 2: totOut  	= 150  	  (fixed)
Parameter 3: In1  	= 145  	  (fixed)
Parameter 4: In2  	= 5  	  (fixed)
Minimum SSD = 5.422; 
Max log-likelihood = -11.129
Correlation matrix = [!!!! PRINTOUT OF CORRELATION MATRIX NOT IMPLEMENTED YET. SORRY.


LIKELIHOOD INTERVALS
2.56-unit Likelihood Intervals  (equivalent SD for Gaussian- 2.26)
Lmax= -11.1287;   Lcrit= -13.687
Parameter 1:   r	= 0.707792	  LOWER = 0.682738	  UPPER = 0.733097
Parameter 2:   totOut	= 150	  (fixed)
Parameter 3:   In1	= 145	  (fixed)
Parameter 4:   In2	= 5	  (fixed)

In [7]:
plX, plY = equation.calculate_plot(set0.X, equation.pars)
rlim = fsession.Llimits[0]
plX1, plY1 = equation.calculate_plot(set0.X, [rlim[0], 150.0, 145.0, 5.0])
plX2, plY2 = equation.calculate_plot(set0.X, [rlim[1], 150.0, 145.0, 5.0])
set0.average_pooled()

In [8]:
plot(set0.X, set0.Y, 'ro') # all data points
errorbar(set0.avX, set0.avY, yerr=set0.avS, fmt='o')
plot(plX, plY, 'b-') # fit
plot(plX1, plY1, 'k--') # lower likelihood limit
plot(plX2, plY2, 'k--') # higher likelihood limit
xlabel('Kout, mM')
ylabel('Erev, mV');



In [ ]: