I was playing around with FindFormula
and am experiencing some odd behavior.
I am running MMA 12.0.0.0 on a Windows 10, x86 architecture - if that matters.
Example 1: All is well
data = Table[{x, Sin[2 x] + Cos[x]}, {x, RandomReal[{-10, 10}, 1000]}];
fits = FindFormula[data, x, 5, All]
This example returns fives formulas consistently and has no issues.
Example 2: Peculiar behaviors
data = {{0, 3}, {2, 5}, {10, 4}, {6, 2}};
ClearAll[fits];
fits = FindFormula[data, x, 5, All]
The behavior is quite peculiar.
- Sometimes it returns 1 correct formula followed by 4 numbers. What are those 4 numbers supposed to represent?
- Sometimes it returns 3 or 4 correct formulas followed by 2 or 1 numbers.
- Sometimes it returns five correct formulas (most infrequent).
To see this behavior, just keep running the last commands again and do it multiple times.
Here is an image to show some of these behaviors.
Can someone explain what is going on?
y == constant
. I believe thatFindFormula
uses stochastic heuristics, which accounts for the different results over multiple calls. $\endgroup$FindFormula
should be renamedWishfulThinking
. One tends to get a constant (such a 3.5 which is the mean of the response variable) when there are very few data points and not much of a relationship. Getting a constant as the predictor does not automatically mean there is a poor fit. There just might not be much of a relationship to fit. $\endgroup$