Why Does FindFit Fail with Non-Real Number Errors in Mathematica?

  • Thread starter Hoiya
  • Start date
In summary, the conversation is about using the FindFit function to fit a function (Espo) to a set of values (Oscill) and encountering an error message. The error message is related to the use of the function e^ instead of E^ in the definition of Espo.
  • #1
Hoiya
2
0
I have these values:

Oscill = {{0, -6.4}, {5, -6.3}, {10, -6.5}, {15, -6.2}, {20, -6.1}, \
{25, -5.9}, {30, -5.8}, {35, -5.5}, {40, -5.1}, {45, -4.8}, {50, \
-4.4}, {55, -3.9}, {60, -3.3}, {65, -2.8}, {70, -2.2}, {75, -1.8}, \
{80, -1}, {85, -0.4}, {90, 0.4}, {95, 1}, {100, 1.8}, {105,
2.3}, {110, 3}, {115, 3.8}, {120, 4.9}, {140, 8}, {160,
11.1}, {180, 13.8}, {200, 16.3}, {220, 18.2}, {240, 19.7}, {260,
20.4}, {280, 20.4}, {300, 19.8}, {320, 18.7}, {340, 17}, {360,
15}, {380, 12.7}, {400, 10.3}, {420, 7.8}, {440, 5.5}, {460,
3.6}, {480, 1.8}, {500, 0.6}, {520, -0.2}, {540, -0.3}, {560,
0}, {580, 0.8}, {600, 1.9}, {620, 3.5}, {640, 5.2}, {660,
7.1}, {680, 8.9}, {700, 10.8}, {720, 12.4}, {740, 13.8}, {760,
14.7}, {780, 15.5}, {800, 15.8}, {820, 15.6}, {840, 15.1}, {860,
14.3}, {880, 13.1}, {900, 11.8}, {920, 10.4}, {940, 8.9}, {960,
7.5}, {980, 6.1}, {1000, 5}, {1020, 4.2}, {1040, 3.6}, {1060,
3.2}, {1080, 3.3}, {1100, 3.6}, {1120, 4.1}, {1140, 4.9}, {1160,
5.8}, {1180, 7}, {1200, 8.1}, {1220, 9.2}, {1240, 10.3}, {1260,
11.2}, {1280, 11.9}, {1300, 12.4}, {1320, 12.8}, {1340,
12.8}, {1360, 12.7}, {1380, 12.3}, {1400, 11.7}, {1420, 11}, {1440,
10.1}, {1460, 9.3}, {1480, 8.4}, {1500, 7.6}, {1520, 6.8}, {1540,
6.3}, {1560, 5.7}, {1580, 5.4}, {1600, 5.3}, {1620, 5.4}, {1640,
5.7}, {1660, 6}, {1680, 6.4}, {1700, 7}, {1720, 7.8}, {1740,
8.4}, {1760, 9}, {1780, 9.6}, {1800, 10.1}, {1820, 10.6}, {1840,
10.8}, {1860, 10.9}, {1880, 10.9}, {1900, 10.8}, {1920,
10.6}, {1940, 10.1}, {1960, 9.7}, {1980, 9.2}, {2000, 8.7}, {2020,
8.1}, {2040, 7.7}, {2060, 7.1}, {2080, 6.9}, {2100, 6.6}, {2120,
6.5}, {2140, 6.5}, {2160, 6.5}, {2180, 6.7}, {2200, 7}, {2220,
7.2}, {2240, 7.7}, {2260, 8.1}, {2280, 8.4}, {2300, 8.9}, {2320,
9.1}, {2340, 9.5}, {2360, 9.7}, {2380, 9.8}, {2400, 9.9}, {2420,
9.8}, {2440, 9.8}, {2460, 9.7}, {2480, 9.3}, {2500, 9.1}, {2520,
8.8}, {2540, 8.6}, {2560, 8.2}, {2580, 8}, {2600, 7.7}, {2620,
7.5}, {2640, 7.4}, {2660, 7.3}, {2680, 7.4}, {2700, 7.4}, {2720,
7.5}, {2740, 7.6}, {2760, 7.8}, {2780, 8}, {2800, 8.2}, {2820,
8.5}, {2840, 8.7}, {2860, 8.9}, {2880, 9}, {2900, 9.1}, {2920,
9.2}, {2940, 9.3}, {2960, 9.3}, {2980, 9.2}, {3000, 9.1}, {3020,
9}, {3040, 8.9}, {3060, 8.7}, {3080, 8.5}, {3100, 8.3}, {3120,
8.1}, {3140, 8}, {3160, 7.9}, {3180, 7.8}, {3200, 7.7}, {3220,
7.7}, {3240, 7.8}, {3260, 7.8}, {3280, 7.9}, {3300, 8.0}, {3320,
8.1}, {3340, 8.3}, {3360, 8.4}, {3380, 8.5}, {3400, 8.6}, {3420,
8.7}, {3440, 8.8}, {3460, 8.8}, {3480, 8.9}, {3500, 8.9}, {3520,
8.8}, {3540, 8.8}, {3560, 8.7}, {3580, 8.6}, {3600, 8.5}}

and this function:

Espo = A*(e^(-\[Sigma]*t))*Cos[((2*Pi/T)*t) + \[Theta]] + \[Phi]

When I try to use findfit, I read this error message:

FEO = FindFit[Oscill, Espo, {A, \[Sigma], T, \[Theta], \[Phi]}, t]

FindFit::nrlnum: The function value {7.9403,7.3+0.540302/e^5.,7.5+0.540302/e^10.,7.2+0.540302/e^15.,7.1+<<19>>/e^<<4>>,<<1>>,6.8+<<1>>,6.5+0.540302/e^35.,6.1+0.540302/e^40.,5.8+0.540302/e^45.,<<189>>} is not a list of real numbers with dimensions {199} at {A,\[Sigma],T,\[Theta],\[Phi]} = {1.,1.,1.,1.,1.}. >>

FindFit::nrlnum: The function value {7.9403,7.3+0.540302/e^5.,7.5+0.540302/e^10.,7.2+0.540302/e^15.,7.1+<<19>>/e^<<4>>,<<1>>,6.8+<<1>>,6.5+0.540302/e^35.,6.1+0.540302/e^40.,5.8+0.540302/e^45.,<<189>>} is not a list of real numbers with dimensions {199} at {A,\[Sigma],T,\[Theta],\[Phi]} = {1.,1.,1.,1.,1.}. >>

Can anybody help me?
 
Physics news on Phys.org
  • #2
Replace this
Espo = A*(e^...
with this
Espo = A*(E^...
 

1. What is FindFit and why might someone experience problems with it?

FindFit is a function in statistical software, such as MATLAB or R, that is used to fit a mathematical model to a set of data points. This can be useful for analyzing and predicting relationships between variables. Some common problems with FindFit may include difficulties with data formatting, choosing an appropriate model, or convergence issues.

2. How can I ensure that my data is properly formatted for use with FindFit?

To use FindFit successfully, your data should be in a format that is compatible with the software and the chosen model. This may include having the correct number of data points, using the appropriate data types, and organizing the data in a specific way. It is important to carefully read the documentation for the software and model to ensure proper formatting.

3. What can I do if I am having trouble choosing an appropriate model for my data?

If you are unsure about which model to use with FindFit, it may be helpful to consult with a statistician or other expert in the field. They can provide guidance on selecting a suitable model based on your data and research question. Additionally, some software packages may have built-in tools to help with model selection, so be sure to explore those options as well.

4. What are some common reasons for convergence issues with FindFit?

Convergence issues with FindFit can occur for a variety of reasons, including a poorly chosen model, incorrectly specified initial parameter values, or a lack of sufficient data points. It is important to carefully consider these factors and make adjustments as needed to improve the convergence of your model.

5. Is there any additional help available for using FindFit?

In addition to consulting with experts or exploring built-in tools, many software packages offer user forums or online communities where users can ask for help and share tips and tricks for using FindFit. It may also be helpful to consult with the documentation for the software or seek out tutorials or workshops to improve your understanding and use of the function.

Similar threads

  • Programming and Computer Science
2
Replies
41
Views
4K
  • Poll
  • Science and Math Textbooks
Replies
5
Views
12K
  • Poll
  • Science and Math Textbooks
Replies
1
Views
4K
  • Introductory Physics Homework Help
Replies
6
Views
2K
  • Poll
  • Science and Math Textbooks
Replies
4
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
1K
  • STEM Academic Advising
Replies
6
Views
5K
  • Poll
  • Science and Math Textbooks
Replies
1
Views
5K
  • Poll
  • Science and Math Textbooks
Replies
4
Views
5K
  • Poll
  • Science and Math Textbooks
Replies
6
Views
7K
Back
Top