首页 \ 问答 \ Quartz调度程序与设置cron(Quartz scheduler vs setting up cron)

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
更新时间:2023-10-23 10:10

最满意答案

问题是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 then cos(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:

enter image description here

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 ...
  • 根据以上评论,我试图提出一个答案,因为没有其他人提供一些意见 。 我认为你正在使用一个很好的基本程序。 使用更合适的拟合曲线可以获得更好的结果,该拟合曲线包括所有主导动态,但避免过度拟合数据。 根据你的数字,我能想到的最简单的形式是: 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 ...
  • 拟合参数的方差表示基于模型与数据拟合质量的最佳拟合值的不确定性。 也就是说,它描述了价值可以从最佳拟合值变化多少,并且仍然具有几乎与最佳拟合值一样好的拟合。 使用卡方的标准定义, chi_square = ( ( (data - model)/epsilon )**2 ).sum() 和reduced_chi_square = chi_square / (ndata - nvarys) (其中data是数据值的数组, model计算模型的数组, epsilon是数据中的不确定性, ndata是数据点的数量, ...
  • 问题是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. ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。