今天我试图用给定的理论模型拟合实验数据。尽管拟合相当好,但 gnuplot 返回了极高的错误:
Final set of parameters Asymptotic Standard Error
======================= ==========================
A = 1.76654e-11 +/- 2.589e-06 (1.465e+07%)
g = 0.000929911 +/- 1.006e-05 (1.082%)
offset = 0.831727 +/- 0.005273 (0.634%)
x0 = 25.7152 +/- 3768 (1.465e+04%)
Run Code Online (Sandbox Code Playgroud)
特别是,x0 上的误差是我后续计算的重要度量。显然,这个值绝对是无稽之谈,如下图所示。
我该怎么做才能得到有意义的错误?
MWE:
f(x,x0,g) = -16.0*A*(g*(g**2.0-12.0*(x-x0)**2))/(pi*(g**2.0+4.0*(x-x0)**2.0)**3.0) + offset
FIT_LIMIT = 1e-16
A=-1e-3
g=1e-3
offset=0.8
x0 = 25.71514200
fit f(x,x0,g) "data" via A,g,offset,x0
plot "data", f(x,x0,g)
Run Code Online (Sandbox Code Playgroud)
数据: 链接(pastebin)
在调试大型 C 应用程序时,我看到以下奇怪的行为gdb
: 我总是可以按 中断程序Ctrl+C
:
^C
Program received signal SIGINT, Interrupt.
0x76f58964 in select () at ../sysdeps/unix/syscall-template.S:81
81 in ../sysdeps/unix/syscall-template.S
(gdb)
Run Code Online (Sandbox Code Playgroud)
但是,在程序运行足够长的时间后(例如 > 1 天),我再也不能轻易中断程序了。当试图用 中断程序时Ctrl+C
,gdb
只显示
^C
Program received signal SIGINT, Interrupt.
Run Code Online (Sandbox Code Playgroud)
并挂在那里几分钟到几个小时。如果花费的时间超过几分钟,我通常会打开另一个终端并gdb
手动终止才能继续。
问题:这是预期的行为gdb
吗?我可以设置一个选项来避免这种情况吗?
更多细节:
FTL
(https://github.com/pi-hole/FTL)pthreads
Ctrl+C
,gdb
CPU 处于 100%。编辑:更多细节
我perf record -p $(pidof gdb)
在gdb
被冻住的时候跑了大约 10 秒钟。perf report
返回:
90,82% gdb gdb …
Run Code Online (Sandbox Code Playgroud) 我正在使用python
和matplotlib.pyplot
生成复杂的图形输出。我想dotted
结合使用线型,FancyArrowPatch
但未能这样做。
MWE:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
style="Simple,head_width=4,head_length=8"
linestyle="dotted" # or "solid"
kw = dict(arrowstyle=style, linestyle=linestyle, color="b", connectionstyle="arc3,rad=1")
plt.gca().add_patch(patches.FancyArrowPatch((0,1), (1,1), **kw))
plt.savefig("MWE.pdf")
Run Code Online (Sandbox Code Playgroud)
这将生成以下图像:
但是,我想得到类似的东西:
问题:我必须在 MWE 中更改什么才能获得较低的图像?
在各种数值实验中,我看到第一次调用mktime
会以一种糟糕的方式改变结果。如您所见,循环中的第一个结果如果关闭一小时而其他结果很好。我的错误是什么?
看到这个 MWE:
#define _XOPEN_SOURCE
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
int main()
{
int i;
for(i=0;i<3;i++)
{
// Set timestamp
char timestamp[16] = "Feb 27 00:00:19";
// Get local time
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime (&rawtime);
// Interpret time string
struct tm querytime;
// Expected format: Mmm dd hh:mm:ss
// %b = Abbreviated month name
// %e = Day of the month, space-padded ( 1-31)
// %H = Hour in …
Run Code Online (Sandbox Code Playgroud)