Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some data which looks like:

Tdata = {{0., 0.05}, {0.78125, 0.05}, {1.5625, 0.15}, {2.34375, 0.}, {3.125, 
0.}, {3.90625, 0.1}, {4.6875, 0.15}, {5.46875, 0.05}, {6.25, 
0.}, {7.03125, 0.1}, {7.8125, 0.05}, {8.59375, 0.1}, {9.375, 
0.1}, {10.1563, 0.2}, {10.9375, 0.25}, {11.7188, 0.4}, {12.5, 
0.55}, {13.2813, 0.45}, {14.0625, 0.7}, {14.8438, 0.95}, {15.625, 
1.}, {16.4063, 1.8}, {17.1875, 2.}, {17.9688, 2.3}, {18.75, 
2.05}, {19.5313, 2.6}, {20.3125, 3.4}, {21.0938, 4.1}, {21.875, 
4.8}, {22.6563, 4.8}, {23.4375, 5.75}, {24.2188, 6.3}, {25., 
6.45}, {25.7813, 7.15}, {26.5625, 8.8}, {27.3438, 8.6}, {28.125, 
9.25}, {28.9063, 10.35}, {29.6875, 12.1}, {30.4688, 10.6}, {31.25, 
11.6}, {32.0313, 12.7}, {32.8125, 12.6}, {33.5938, 12.75}, {34.375, 
15.3}, {35.1563, 13.25}, {35.9375, 12.35}, {36.7188, 12.65}, {37.5, 
14.1}, {38.2813, 13.5}, {39.0625, 12.5}, {39.8438, 13.6}, {40.625, 
12.4}, {41.4063, 11.15}, {42.1875, 10.65}, {42.9688, 11.3}, {43.75, 
11.45}, {44.5313, 9.95}, {45.3125, 10.4}, {46.0938, 10.45}, {46.875,
8.85}, {47.6563, 9.6}, {48.4375, 8.4}, {49.2188, 8.5}, {50., 
8.05}, {50.7813, 7.9}, {51.5625, 6.95}, {52.3438, 6.85}, {53.125, 
6.2}, {53.9063, 6.6}, {54.6875, 6.6}, {55.4688, 5.25}, {56.25, 
5.45}, {57.0313, 5.35}, {57.8125, 4.5}, {58.5938, 4.1}, {59.375, 
3.6}, {60.1563, 3.5}, {60.9375, 2.95}, {61.7188, 3.05}, {62.5, 
3.1}, {63.2813, 3.15}, {64.0625, 2.85}, {64.8438, 2.35}, {65.625, 
2.15}, {66.4063, 3.1}, {67.1875, 2.5}, {67.9688, 1.95}, {68.75, 
2.45}, {69.5313, 2.}, {70.3125, 1.95}, {71.0938, 1.9}, {71.875, 
1.35}, {72.6563, 1.2}, {73.4375, 1.}, {74.2188, 1.05}, {75., 
1.5}, {75.7813, 1.05}, {76.5625, 1.2}, {77.3438, 1.05}, {78.125, 
0.95}, {78.9063, 0.85}, {79.6875, 0.7}, {80.4688, 1.05}, {81.25, 
0.9}, {82.0313, 0.65}, {82.8125, 0.85}, {83.5938, 0.65}, {84.375, 
0.8}, {85.1563, 0.6}, {85.9375, 0.65}, {86.7188, 0.4}, {87.5, 
0.55}, {88.2813, 0.7}, {89.0625, 0.45}, {89.8438, 0.55}, {90.625, 
0.35}, {91.4063, 0.5}, {92.1875, 0.45}, {92.9688, 0.3}, {93.75, 
0.15}, {94.5313, 0.3}, {95.3125, 0.3}, {96.0938, 0.35}, {96.875, 
0.15}, {97.6563, 0.2}, {98.4375, 0.3}, {99.2188, 0.15}, {100., 
0.3}, {100.781, 0.2}, {101.563, 0.25}, {102.344, 0.45}, {103.125, 
0.1}, {103.906, 0.1}, {104.688, 0.05}, {105.469, 0.3}, {106.25, 
0.1}, {107.031, 0.25}, {107.813, 0.05}, {108.594, 0.15}, {109.375, 
0.05}, {110.156, 0.1}, {110.938, 0.1}, {111.719, 0.05}, {112.5, 
0.}, {113.281, 0.2}, {114.063, 0.05}, {114.844, 0.1}, {115.625, 
0.05}, {116.406, 0.05}, {117.188, 0.1}, {117.969, 0.25}, {118.75, 
0.1}, {119.531, 0.1}, {120.313, 0.}, {121.094, 0.05}, {121.875, 
0.05}, {122.656, 0.05}, {123.438, 0.}, {124.219, 0.05}, {125., 
0.05}, {125.781, 0.}, {126.563, 0.}, {127.344, 0.1}}

enter image description here

I tried to fit this data to a series of polynomials:

sol = Fit[Tdata, Table[x^i, {i, 0, 14}], x]
plot1 = Plot[sol, {x, 1, 120}, PlotStyle -> {Red, Thickness[0.005]}, 
PlotRange -> All];
Show[{plot1, plot}]

0.180145 - 0.202127 x + 0.0517504 x^2 - 0.000786656 x^3 - 
0.000942415 x^4 + 0.000123705 x^5 - 7.22477*10^-6 x^6 + 
2.44885*10^-7 x^7 - 5.32789*10^-9 x^8 + 7.78619*10^-11 x^9 - 
7.75517*10^-13 x^10 + 5.20728*10^-15 x^11 - 2.25919*10^-17 x^12 + 
5.72595*10^-20 x^13 - 6.4449*10^-23 x^14

enter image description here

I know that this data, which obtained experimentally, is the convolution of a Gaussian

function and an exponential.

numberOFexp = 1;

model[z_] := Sum[Subscript[a, i]*Exp[-z/Subscript[\[Tau], i]], {i, 1, numberOFexp}] ;

irf[z_] := (2.0*Sqrt[2*Log[2]])/(\[CapitalDelta]*Sqrt[2.0*Pi])*Exp[-4.0*Log[2]*
((z -\[Mu])/\[CapitalDelta])^2];

model2 = Integrate[irf[z]*model[t - z], {z, 0, t}](*This is what generates the exprimentall data*)

Now, I expand model2 up to the powers by which I fitted the data with polynomials. The point is that in the model2 there are some parameters which I want to know. I had fitted the data with a polynomial with 15 terms. I want to expand model2 up to 15 terms and equate the coefficient of each polynomial of my fit to this expansion and get those unknown parameters. Because I have just 4 unknown I decided to expand model2 up to 4 term. I tried:

model3 = Normal[Series[model2, {t, 36, 3}]];

unknowns= CoefficientList[model3, t];
co2 = CoefficientList[sol, x];
co3 = co2[[1 ;; 4]]
NSolve[unknowns==co3 , {\[CapitalDelta], \[Mu], Subscript[\[Tau], 1], Subscript[a, 1]}, Reals] 

However, this can't find the solution.

share|improve this question

closed as off-topic by Louis, RunnyKine, MarcoB, m_goldberg, JasonB Apr 27 at 7:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Louis, RunnyKine
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Several items are not defined, such as co and Tdata and plot. Also it is not entirely clear (to me at least) what it is you want. – Daniel Lichtblau May 13 '14 at 14:26
    
@DanielLichtblau. I edited the code. Tdata is data which I introduced first.plot is the plot of the Tdata. – MOON May 13 '14 at 19:16
    
If you know that your data is a convolution of Gaussian and exponential, I'd suggest that you take a look at the procedure I proposed in this older answer of mine, which recovers the parameters of the exponential directly: List Deconvolution. – MarcoB Apr 26 at 19:41
    
Possible duplicate of List Deconvolution – MarcoB Apr 26 at 19:42
1  
I'm voting to close this question as off-topic because the OP appears to have found the bugs in his code and has abandon the question. – m_goldberg Apr 26 at 23:59
data = Tdata;  (* OP changed variable in question *)
numberOFexp = 1;

model[z_] := Sum[a[i]*Exp[-z/tau[i]], {i, 1, numberOFexp}];

irf[z_] := (2.0*Sqrt[2*Log[2]])/(delta*Sqrt[2.0*Pi])* Exp[-4.0*Log[2]*((z - mu)/delta)^2];

model2 = Integrate[irf[z]*model[t - z], {z, 0, t}];
fit = FindFit[data, model2, {delta, mu, tau[1], a[1]}, {t}]
modelf = Function[{t}, Evaluate[model2 /. fit]];
Plot[modelf[t], {t, 0, 128}, Epilog -> Map[Point, data]]
Panel[TableForm[CoefficientList[Series[modelf[t], {t, 0, 14}], t], 
                TableHeadings -> {Range[0, 14], {"Coeff"}}], "Coefficients"]

Mathematica graphics

Mathematica graphics

share|improve this answer
    
Thank you. Actually, I did not want the coefficient of the expansion of the fit. I already had them. I needed to know tau1,a1 delta, and mu. I looked at your code and your FindFit code notice a mistake in my code. In my code I had included a constraint for the variables I wanted to know. However, there was a typo and so there could not be a solution. Even after correcting the typo, I realized that having constraint on my unknowns causes underflow. Finally, without any constraint I got the unknowns I wanted. – MOON May 13 '14 at 19:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.