In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use python to do data fitting. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
1. Example: fit a function Func, here is an exponential function.
Provenance:
SciPy v1.1.0 Reference Guide
# Headerimport numpy as npimport matplotlib.pyplot as pltfrom scipy.optimize import curve_fit#Define a function (here an exponential function is used) def func (x, a, b, c): return a * np.exp (- b * x) + c#Create the data to be fit with some noisexdata = np.linspace (0,4,50) y = func (xdata, 2.5,1.3,0.5) np.random.seed (1729) y_noise = 0.2 * np.random.normal (size=xdata.size) ydata = y + y_noiseplt.plot (xdata Ydata, 'bo', label='data') # Fit for the parameters aforme b, c of the function func:popt, pcov = curve_fit (func, xdata, ydata) popt # output: array ([2.55423706, 1.35190947, 0.47450618]) plt.plot (xdata, func (xdata, * popt),' r Mustang, label='fit: asides% 5.3f, baked% 5.3f, cations% 5.3f'% tuple (popt)) # In the case of parameters aforb C need be constrainted#Constrain the optimization to the region of # 0
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.