# FindFit and NIntegrate with dependency between integration variables

I am trying to use FindFit and NIntegrate in this situation:

fitfun[x_, a_, b_] :=
NIntegrate[fun1[x, t1, a, b] fun2[x, t2, a ,b], {t1, -1, 1}, {t2, -∞, t1}]


I have tried the trick defining fitfun[x_?NumericQ, a_?NumericQ, b_?NumericQ], but the dependent integration bound still seems to be leaving something symbolic around that FindFit does not like. For example, if I just make {t2, -∞, 10}, then everything works, despite now being incorrect.

I am hoping for a simple trick to fix this problem.

Edit: A possible solution has been found using Module.

Module[{fitfun}, fitfun[x_?NumericQ,a_?NumericQ,b_?NumericQ,]:=NIntegrate[fun1[x, t1, a, b] fun2[x, t2, a ,b],{t1, -1, 1}, {t2, -∞, t1}]; FindFit[data,Evaluate@fitfun,parameters,vars] ]

A friend of mine found this so I can't take credit for it. I think whether or not you want to define everything inside module or just the fitting function shouldn't matter.

-
Does this work: fitfun[x_?NumericQ, a_?NumericQ, b_?NumericQ] := NIntegrate[Boole[-inf <= t2 <= t1] fun1[x, t1, a, b] fun2[x, t2, a, b], {t1, -1, 1}, {t2, -Infinity, Infinity}]? –  kguler Mar 18 '13 at 18:24
$\infty$ is spelt Infinity in Mathematica. Is -inf a mistake? –  Szabolcs Mar 18 '13 at 18:41
Unfortunately NIntegrate is still complaining about non-numerical values with this addition. I also tried making a new Boole function that uses the _?NumericQ as inputs, but with not luck. –  Bert Mar 18 '13 at 18:42
I wrote "-inf" because I was being lazy on the thread. A friend of mine has figured out a work around using Module. Module[{fitfun}, fitfun[x_?NumericQ,a_?NumericQ,b_?NumericQ]:=NIntegrate[fun1[x,t1,a,b]fun2[x,t2,‌​a,b],{t1,-1,1},{t2,-inf,t1}]; FindFit[data, Evaluate@fitfun, params, vars] ] –  Bert Mar 18 '13 at 19:00