Mathematica to FindFit for multiple data set

Click For Summary
SUMMARY

The discussion centers on using Mathematica to fit multiple data sets simultaneously with the function y=ax+b, where each data set has unique parameters a and b. The solution provided involves utilizing the Map function in Mathematica to apply FindFit across a collection of data sets. The specific implementation shared is: Map[FindFit[#, a x + b, {a, b}, x] &, {data1, data2, data3}]. This approach effectively streamlines the fitting process for multiple data sets.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of the FindFit function in Mathematica
  • Basic knowledge of linear regression concepts
  • Experience with data manipulation in Mathematica
NEXT STEPS
  • Explore advanced features of the FindFit function in Mathematica
  • Learn about the Map function and its applications in Mathematica
  • Investigate techniques for optimizing data fitting processes
  • Study examples of fitting multiple datasets in Mathematica
USEFUL FOR

Data scientists, researchers, and analysts who need to perform simultaneous data fitting in Mathematica, particularly those working with multiple datasets requiring linear regression analysis.

Sue Laplace
Messages
10
Reaction score
0
After conducting my experimental work I will have a number of sets of data.

It is easy to use Mathematica to find a fit of just one set, but I would like to fit all sets at once as they are too many to do them all ate once.
They will all be fitted by the same function say y=ax+b, every set having a different value of a and b.

How do I do this?
Thanks in advance.
Sue
 
Physics news on Phys.org
Without a concrete specific example it is perhaps difficult to know exactly what the answer should be.

Usually if you want to "do the same thing to a collection of items" Map[] is the solution.

data1={...};
data2={...};
data3={...};
Map[FindFit[#,a x+b,{a,b},x]&,{data1,data2,data3}]

may do what you want.

http://reference.wolfram.com/mathematica/ref/Map.html
 
Last edited:
Thank you very much Bill, it is working.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
9K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K