Quartz调度程序与设置cron(Quartz scheduler vs setting up cron)
计划从设置cron作业转向Quartz调度程序。 使用Quartz而不是设置cron有什么优缺点?
得到这个时间触发的工作Cron或Quartz? 链接。 还有其他指针吗?
Was planning to move from setting up cron jobs to Quartz scheduler. What are the pros/cons of using Quartz rather than setting up cron ?
Got this Time triggered job Cron or Quartz? link. Any other pointers ?
原文:https://stackoverflow.com/questions/9478150
最满意答案
问题是
cos(x)
可能变为负数,然后cos(x) ^ n
可能是未定义的。 插图:np.cos(90) -0.44807361612917013
例如
np.cos(90) ** 1.7 nan
这会导致您收到两条错误消息。
如果您修改模型,它可以正常工作,例如
a + b * np.cos(c * x + d)
。 然后情节如下:代码可以在下面找到一些内联注释:
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def f(x, a, b, c, d): return a + b * np.cos(c * x + d) # your data xdata = [90, 60, 45, 30, 0] ydata = [3.3888756187, 2.7662844365, 2.137309503, 1.5256883339, 1.4665463518] # plot data plt.plot(xdata, ydata, 'bo', label='data') # fit the data popt, pcov = curve_fit(f, xdata, ydata, p0=[3., .5, 0.1, 10.]) # plot the result xdata_new = np.linspace(0, 100, 200) plt.plot(xdata_new, f(xdata_new, *popt), 'r-', label='fit') plt.legend(loc='best') plt.show()
The problem is that
cos(x)
can become negative and thencos(x) ^ n
can be undefined. Illustration:np.cos(90) -0.44807361612917013
and e.g.
np.cos(90) ** 1.7 nan
That causes the two error messages you receive.
It works fine, if you modify your model, e.g. to
a + b * np.cos(c * x + d)
. Then the plot looks as follows:The code can be found below with some inline comments:
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit def f(x, a, b, c, d): return a + b * np.cos(c * x + d) # your data xdata = [90, 60, 45, 30, 0] ydata = [3.3888756187, 2.7662844365, 2.137309503, 1.5256883339, 1.4665463518] # plot data plt.plot(xdata, ydata, 'bo', label='data') # fit the data popt, pcov = curve_fit(f, xdata, ydata, p0=[3., .5, 0.1, 10.]) # plot the result xdata_new = np.linspace(0, 100, 200) plt.plot(xdata_new, f(xdata_new, *popt), 'r-', label='fit') plt.legend(loc='best') plt.show()
相关问答
更多-
对于拟合y = A + B log x ,只适合y (log x )。 >>> x = numpy.array([1, 7, 20, 50, 79]) >>> y = numpy.array([10, 19, 30, 35, 51]) >>> numpy.polyfit(numpy.log(x), y, 1) array([ 8.46295607, 6.61867463]) # y ≈ 8.46 log(x) + 6.62 对于拟合y = Ae Bx ,取两边的对数给出log y = log A + B ...
-
预测曲线拟合matlab(Predictive curve fitting matlab)[2022-10-18]
根据以上评论,我试图提出一个答案,因为没有其他人提供一些意见 。 我认为你正在使用一个很好的基本程序。 使用更合适的拟合曲线可以获得更好的结果,该拟合曲线包括所有主导动态,但避免过度拟合数据。 根据你的数字,我能想到的最简单的形式是: s + a(1-e^(-t/tau)) 参数s (初始温度), a (振幅=稳态值)和tau (主时间常数)。 正如你自己提到的那样,限制参数的允许范围可能会避免过度拟合并提高估算的质量。 使用一个随机的高阶函数,就像你现在使用的那样,可能会给出很好的插值结果,但是对于外推 ... -
我认为前一行中有一个括号问题。 这会导致返回包含在公式中。 我认为最后有一个缺失。 I think there is a parenthesis problem in the previous line. This causes the return to be included in the formula. I think there's a ) missing at the end.
-
由于许多曲线可以适合数据并以不同方式推断,因此您需要选择正确的基函数来获得所需的行为。 到目前为止,你已经尝试过多项式,然而这些往往是+ - 无限,这可能不是你想要的。 我会尝试在Hermite多项式或Laguerre多项式之和上使用curve_fit。 例如,对于Laguerre多项式,您可以尝试 a + b*exp(-k x) + c*(1-x)*exp(-k x) + d*(x^2 - 4*x + 2)*exp(-k x) + ... Python内置了许多便利函数,例如https://docs.s ...
-
你有这个功能,它是理性的功能。 因此,您需要设置功能并执行拟合。 由于curve_fit要求你提供的参数不是列表,我提供了一个附加函数,它在分子和分母中对三次多项式的特定情况进行拟合。 def rational(x, p, q): """ The general rational function description. p is a list with the polynomial coefficients in the numerator q is a list wit ...
-
你可以这样做: print "Mean Squared Error: ", np.mean((y-func(x, *popt))**2) ss_res = np.dot((yn - func(x, *popt)),(yn - func(x, *popt))) ymean = np.mean(yn) ss_tot = np.dot((yn-ymean),(yn-ymean)) print "Mean R :", 1-ss_res/ss_tot 这是直接获取定义,例如在维基百科中: http : //en ...
-
SciPy曲线拟合参数的确切变化是什么?(What exactly is the variance on the parameters of SciPy curve fit? (Python))[2022-02-21]
拟合参数的方差表示基于模型与数据拟合质量的最佳拟合值的不确定性。 也就是说,它描述了价值可以从最佳拟合值变化多少,并且仍然具有几乎与最佳拟合值一样好的拟合。 使用卡方的标准定义, chi_square = ( ( (data - model)/epsilon )**2 ).sum() 和reduced_chi_square = chi_square / (ndata - nvarys) (其中data是数据值的数组, model计算模型的数组, epsilon是数据中的不确定性, ndata是数据点的数量, ... -
曲线拟合与python错误(Curve fitting with python error)[2022-06-05]
问题是cos(x)可能变为负数,然后cos(x) ^ n可能是未定义的。 插图: np.cos(90) -0.44807361612917013 例如 np.cos(90) ** 1.7 nan 这会导致您收到两条错误消息。 如果您修改模型,它可以正常工作,例如a + b * np.cos(c * x + d) 。 然后情节如下: 代码可以在下面找到一些内联注释: import numpy as np import matplotlib.pyplot as plt from scipy.optimize ... -
由于以下两个原因,你会感到不适合: 您的模型不适合您的数据。 适合数字病态。 你可以改进模型的数值条件,将常数A移动到指数exp(-K*(t - t_0)) + C 你得到这种方式的结果与指数模型一样好。 在日志空间中拟合也无济于事(只要你的模型中有加性常数C ,它就不是一个真正的选项)。 You get a bad fit because of two reasons: Your model isn't a particular good fit for your data. The fit is num ...
-
您正在尝试使用尚未转换为对数空间的Y来计算R平方。 以下更改给出了合理的R平方值: R2 = R_sqr(np.log(bins[:,1]), np.log(y_predict)) You are trying to calculate an R-squared using Y's that have not been converted to log-space. The following change gives reasonable R-squared values: R2 = R_sqr(np. ...