0

I have written the codes below:

def model(axis, p):
    a1, t1, a2, t2, a3, t3, a4, t4 = p
    return a1*np.exp(-axis/t1) + a2*np.exp(-axis/t2) + a3*np.exp(-axis/t3) + a4*np.exp(-  axis/t4)

This code is the definition of 4 exponentials. I have to convolve this functions, which

returns a series in different time points, with another series. To do this I have written

the code below:

def Recsig(N, irf, model):
    conv_sig = [0.0]*irf.size
    for n in range(0,N+1):
        SUM = 0.0
        for m in range(0, n+1):
            SUM = irf[m]*model[n-m] + SUM
            conv_sig[n] = SUM
    result = np.squeeze(conv_sig)
    return result

The result of Recsig function must be a series. I have another series obtained by

experiment. The goal is to use nonlinear least squares method, experimental series, and

Recsig to find the parameters in function model, a1,t1 .... a4,t4.

The problem is that model function does not accept parameter when I want to call it. As a result I cannot make a series of 4 exponentials and give it to Recsig function.


More explanation:

I measured the fluorescence emission of some kind of bacteria in time using TCSPC set up,

time correlated single photon counting. The recorded signal or fluorescence is the

convolution of IRF, instrument response function, and a model, in this case a 4

exponential function. I want to convolve, do the convolution, irf and the model. Then I

will have the result of this convolution as a series in time. Each element of the series is

the value of convolution in a point in time. Now, I can use the convolution series and

recorded fluorescence to estimate the free parameters in model.

The problem is that I cannot turn the model function into a series with a given time axis.

numpy.exp(axis/t1)tries to evaluate the numerical value of this exponential, but just axis

is a numerical value and t1 is a parameter yet to bet determined in the fitting. As a

result mumpy cannot turn the model function into a series.

MOON
  • 2,516
  • 4
  • 31
  • 49
  • What are you expecting the function `model()` to return? – kylieCatt Mar 19 '14 at 00:11
  • Function `model()` must return the 4 exponentials in different time points, at time 0,1,2,.... . The only numerical input must be `axis` which is the time axis. The other parameters of function `model` such as `a1`and `t1` will be calculated in the fitting procedure. – MOON Mar 19 '14 at 00:19
  • I'm pretty sure you don't have that set up properly. As of now you have all those variables set to be the same thing, `p`. If you want to have different calues you are going to need to assign them differently. – kylieCatt Mar 19 '14 at 00:22
  • How can I give the function `model` just the axis and get a series? – MOON Mar 19 '14 at 00:47
  • Sorry, it's been a while since I have done any math. If you could edit your question to show what results you would like to get I can help you. – kylieCatt Mar 19 '14 at 01:52

0 Answers0