I have a large data set made up of triples, (x, y, f(x,y)), x, y and f(x,y) are all integers. I don't know the function f(x, y) and my goal is to find (estimate) it. I do know that x can be any positive integer and y varies from 2 to x. We have a feeling that f(x,y) involves x!. This seems to be a surface fitting problem. However, it seems that MATLAB doesn't have a way to do surface fitting for a factorial function. Does Mathematica, SAS or any other software have this capability? Any help in this regard will be highly appreciated.


closed as off-topic by MarcoB, user9660, Kuba, Yves Klett, Michael E2 Jun 28 '16 at 16:32

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

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – MarcoB, Community, Kuba, Yves Klett, Michael E2
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ As the lot of us neither have your data nor any capability to read your mind, it will be difficult to help you unless you can resolve one of those two concerns. $\endgroup$ – J. M. will be back soon Jun 27 '16 at 10:32
  • $\begingroup$ How about something like FindFormula[data, {x,y}, TargetFunctions -> {Gamma[x]}?, Perhaps there's a way to specify Integers? $\endgroup$ – Feyre Jun 27 '16 at 11:30

I am going to give an answer from my hunch. Say your function is 0.3 y + 2/x!. To fit this function you can use Gamma[x] instead of x!. The result would not be very good as the interpolation will go over non integer values as well.

data = Flatten[Table[{x, y, .3 y + 2/x!}, {x, 0, 10}, {y, 0, 10}], 1];

f = a /Gamma[x] + b y
FindFit[data, f, {a, b}, {x, y}]

{a -> 1.23441, b -> 0.327027}

For a better answer, we need better information. After all, as J.M. pointed out, we can't read your mind :)

  • $\begingroup$ OP states "x, y and f(x,y) are all integers" so the choice of function is perhaps a bit poor. But the method you show is of course the point, and a good one :) $\endgroup$ – Marius Ladegård Meyer Jun 27 '16 at 11:11
  • 1
    $\begingroup$ Adjust your model since x! == Gamma[x+1] and the fit will be very good. Or just use x! since it is defined for more than just integers. $\endgroup$ – Bob Hanlon Jun 27 '16 at 13:45

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