I am looking for defining a function returning a function. This function must return a polynomial fit. I managed to pass the function to fit as argument but i stuggle with the returned value of the function.
With the code below I get fit but this do not seem to be a pure function. This is a problem because the code after needs pure functions.
GetFitProba[f_Symbol, T_, V_, eta_, cut_, t_] := ( data = Transpose[ List[Table[i, {i, IntegerPart[cut], V}], f[#, T, V, eta, t] & /@ Table[i, {i, IntegerPart[cut], V}]]]; fit = LinearModelFit[ data, {1, x, x^2, x^3, x^4, x^5, x^6, x^8, x^9, x^10, x^11, x^12}, x]; fit[x] ) Then I call it like that:
h[x_] := GetFitProba[f, T, V, eta, cut, t]; (where f, t, V, eta, cut, and t are well defined)
I think the problem come from the objet returned by LinearModelFit (which is a FittedModel) but I do not understand how I am supposed to managed it. I tried to return Normal[fit] and things like that but it didn't work.
Thank you for your help !
fitworks like a function when applied to numbers. If you want to return a function, returnfit. Otherwise there are various pieces of information you can extract fromfitusingfit["property"]. The possible properties are documented in theLinearModelFitpage. Always look under Details and Options. $\endgroup$