- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试过运行这段代码,但无论我如何简化它,我总是遇到同样的错误。
/home/runner/.site-packages/symfit/core/fit.py:1046: RuntimeWarning:divide by zero encountered in true_divide W = 1/sigma**2/s_sq[:,np.newaxis]
/home/runner/.site-packages/symfit/core/fit.py:1783:> RuntimeWarning: invalid value encountered in double_scalars return 1 SS_res/SS_tot
帮助将不胜感激。
x1, ya = sf.variables('x1, ya')
I1, I2, I3, A, B, C, D = sf.parameters('I1, I2, I3, A, B, C, D')
I1.value = 46.483
I2.value = 5.916
I3.value = 21.90
A.value = -3.828*10**(-5)
B.value = 0
C.value = 0
D.value = 0
# Making the equation
ya = (A*x1**3 + B*x1**2 + C*x1 + D + (q_subm*x1**4)/(24*EI)) #q_sub and EI are constants
#model = Model({y: Piecewise((ya, x1 <= I1), (yb, x2 <= I2), (yc, x3 <= I3))})
model = Model({ya})
# As a constraint, we want cable to be at 0 at start and and at "-p" height at x=60
# also no angle in pipe ate those points
constraints = [
Eq(ya.subs({x1: 0}), 0),
Eq(ya.subs({x1: 60}), -p),
Eq(ya.diff(x1).subs({x1: 0}), 0),
Eq(ya.diff(x1).subs({x1: 60}), 0)
]
x1data = np.linspace(0, 60., 60)
y1data = model(x1=x1data, A = -3.828*10**(-5), B = 0, C = 0, D = 0)
np.random.seed(2)
y1data = np.random.normal(y1data, 0.005)
plt.plot([60], [0.4], 'ro')
plt.scatter(x1data, y1data)
plt.savefig('plot.png')
print ('Done plotting fig')
#fit = Fit(model, x=xdata, y=ydata, constraints=constraints)
fit = Fit(model, x1=x1data, constraints=constraints)
print ('Done fitting model')
fit_result = fit.execute()
#print(fit_result)
最佳答案
我对您的代码有一些评论,也许其中之一可以解决问题。
model = Model({ya})
错误地尝试从集合中构建模型,因为 {}
构建了集合。尝试使用 model = Model({y: ya})
或 model = Model(ya)
代替。 (我会推荐第一个)fit = Fit(model, x=x1data , y=y1data, constraints=constraints)
基本上是正确的,请注意我更改了数据数组的名称以包含 1
。上面示例中的行无法工作,因为您没有提供 ydata。q_subm
和EI
的类型
是什么?只要它们是标准的 Python 数字类型就没问题,但如果它们是奇异的东西,则可能会导致问题。警告
,只要结果正确,在拟合过程中出现一些警告就没有问题。我希望这能解决问题,如果不能让我知道。
x1, y = sf.variables('x1, y')
I1, I2, I3, A, B, C, D = sf.parameters('I1, I2, I3, A, B, C, D')
I1.value = 46.483
I2.value = 5.916
I3.value = 21.90
A.value = -3.828*10**(-5)
B.value = 0
C.value = 0
D.value = 0
# Making the equation
ya = (A*x1**3 + B*x1**2 + C*x1 + D + (q_subm*x1**4)/(24*EI)) #q_sub and EI are constants
model = Model({y: ya})
# As a constraint, we want cable to be at 0 at start and and at "-p" height at x=60
# also no angle in pipe ate those points
constraints = [
Eq(ya.subs({x1: 0}), 0),
Eq(ya.subs({x1: 60}), -p),
Eq(ya.diff(x1).subs({x1: 0}), 0),
Eq(ya.diff(x1).subs({x1: 60}), 0)
]
x1data = np.linspace(0, 60., 60)
y1data = model(x1=x1data, A=-3.828*10**(-5), B=0, C=0, D=0)
np.random.seed(2)
y1data = np.random.normal(y1data, 0.005)
plt.plot([60], [0.4], 'ro')
plt.scatter(x1data, y1data)
plt.savefig('plot.png')
print ('Done plotting fig')
fit = Fit(model, x=x1data, y=y1data, constraints=constraints)
fit_result = fit.execute()
print ('Done fitting model')
print(fit_result)
关于python - 运行时警告 : divide by zero encountered in true_divide W = 1/sigma**2/s_sq symfit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54905295/
我使用 scipy.stats.spearmanr(a,b) 我得到: Warning: divide by zero encountered in divide 操作正确结束,但显示警告。 a 和
我使用 , 比如 .我认为使用 like 没问题.然而,有时不显示。 我用了在 ,但是 未显示。我应该只使用 吗?在 ? 如果有人遇到与我相同的问题,请分享您解决此问题的经验。 这是我的代码
I am trying to divide a very large even number 13144131834269512219260941993714669605006625743172006
我向 Mongo DB 创建了一个请求: { $project: { difference: { $subtract:
我有一个 JavaFX 应用程序 拆分 Pane .我想禁用 分隔线 在 拆分 Pane ,因此在应用程序运行时无法更改其位置。我怎样才能做到这一点? 最佳答案 没有 API,所以一旦显示了场景,我们
我尝试做一个简单的 Swing 窗,但布局并不容易...我的意思是我只想要一个有 3 个面板的窗口: 标题占窗口高度的 20% 内容占窗口高度的 60% 页脚占窗口高度的 20% 但我无法成功拥有我想
我尝试做一个简单的 Swing 窗,但布局并不容易...我的意思是我只想要一个有 3 个面板的窗口: 标题占窗口高度的 20% 内容占窗口高度的 60% 页脚占窗口高度的 20% 但我无法成功拥有我想
我正在尝试替换字符串中的字符。假设字符串是: "yaaaaaaaay:axaxaxaxa:yaaaaaaay" 我希望java将:之后的所有a更改为X,直到下一个:。所以它看起来像这样: "yaaaa
我在下面的代码中尝试 Perl 的 PDL: #!/usr/bin/perl -w use strict; use PDL::Core qw(pdl); use PDL::Math qw(isfin
这个问题已经有答案了: Is floating point math broken? (33 个回答) 已关闭 7 年前。 我在使用 BigDecimal 执行除法时得到不正确的结果。数字1 = 22
只是一个简单的问题,我无法理解,希望你们能帮忙。 我有一个div (带有 ID),单击时将打开一个新的 div - 很好,效果很好,我真正想要的是“填充”新的 div带有基于单击的 div ID 的预
我正在使用 BigDecimal 进行一些浮点运算。如果将 5 除以 4.2,您将得到一个异常(因为结果有一个不能用 BigDecimal 表示的非终止扩展) )即 BigDecimal five =
我的目标是获得类似于下图所示的分隔线: Goal Picture Divider 我需要在 LinearLayout 之间放置一个水平和垂直分隔线 这是我的用户界面 XML 代码:
我正在尝试以 Angular Testing 弹出组件,但我不知道为什么当我启动测试时出现错误: 'mat-divider' is not a known element: 1. If 'mat-di
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我知道 md-divider 用于 md-list 但我希望它在 flex-layout 中 例如: 应该在两个 div 之间有一个水平分隔线,对于另一种情况
当我尝试除以 0 时,以下代码没有捕获异常。我需要抛出异常,还是计算机会在运行时自动抛出异常? int i = 0; cin >> i; // what if someone enters zero
当我尝试除以 0 时,以下代码没有捕获异常。我需要抛出异常,还是计算机会在运行时自动抛出异常? int i = 0; cin >> i; // what if someone enters zero
这个问题在这里已经有了答案: Division by zero: Undefined Behavior or Implementation Defined in C and/or C++? (8 个
我的代码将以这种方式工作: input : a[]="create /dir/bar" 并保存在这个字符串中: b[]=create c[]=/dir/bar 还有一种情况是我保存了另外一个字符串:
我是一名优秀的程序员,十分优秀!