- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 lmfit 拟合部分数据(应该看起来像高斯),但我得到了一条线。请参见下图。
数据绘图:
我尝试过的代码如下:
import matplotlib.pyplot as plt
from numpy import sqrt, pi, exp, linspace, loadtxt
from lmfit import Model
def gaussian(x, amp, cen, wid):
"1-d gaussian: gaussian(x, amp, cen, wid)"
return (amp/(sqrt(2*pi)*wid)) * exp(-(x-cen)**2 /(2*wid**2))
gmodel = Model(gaussian)
result = gmodel.fit(n[83:93], x=bins[84:94], amp=2, cen=5, wid=3)
print result.fit_report()
ax = plt.subplot(212)
ax.set_yscale("log", nonposx='clip')
plt.plot(bins[1:len(bins)], n, 'r*')
plt.plot(bins[84:94], result.init_fit, 'r')
plt.grid()
plt.ylabel("Counts")
plt.xlabel("Peak Voltage [V]")
plt.show()
遵循我正在使用的数据系列
垃圾箱
array([ 0.381058 , 0.41177682, 0.44249564, 0.47321446, 0.50393328,
0.5346521 , 0.56537092, 0.59608974, 0.62680856, 0.65752738,
0.6882462 , 0.71896502, 0.74968384, 0.78040266, 0.81112148,
0.8418403 , 0.87255912, 0.90327794, 0.93399676, 0.96471558,
0.9954344 , 1.02615322, 1.05687204, 1.08759086, 1.11830968,
1.1490285 , 1.17974732, 1.21046614, 1.24118496, 1.27190378,
1.3026226 , 1.33334142, 1.36406024, 1.39477906, 1.42549788,
1.4562167 , 1.48693552, 1.51765434, 1.54837316, 1.57909198,
1.6098108 , 1.64052962, 1.67124844, 1.70196726, 1.73268608,
1.7634049 , 1.79412372, 1.82484254, 1.85556136, 1.88628018,
1.916999 , 1.94771782, 1.97843664, 2.00915546, 2.03987428,
2.0705931 , 2.10131192, 2.13203074, 2.16274956, 2.19346838,
2.2241872 , 2.25490602, 2.28562484, 2.31634366, 2.34706248,
2.3777813 , 2.40850012, 2.43921894, 2.46993776, 2.50065658,
2.5313754 , 2.56209422, 2.59281304, 2.62353186, 2.65425068,
2.6849695 , 2.71568832, 2.74640714, 2.77712596, 2.80784478,
2.8385636 , 2.86928242, 2.90000124, 2.93072006, 2.96143888,
2.9921577 , 3.02287652, 3.05359534, 3.08431416, 3.11503298,
3.1457518 , 3.17647062, 3.20718944, 3.23790826, 3.26862708,
3.2993459 , 3.33006472, 3.36078354, 3.39150236, 3.42222118,
3.45294 ])
和
array([ 33., 173., 178., 187., 212., 196., 194., 218., 213.,
191., 189., 236., 115., 196., 211., 182., 163., 161.,
125., 123., 116., 133., 104., 120., 68., 138., 91.,
81., 92., 76., 89., 84., 96., 86., 71., 69.,
78., 48., 84., 76., 75., 99., 73., 64., 93.,
67., 92., 85., 101., 38., 88., 65., 54., 76.,
63., 51., 78., 81., 67., 50., 79., 63., 24.,
50., 68., 58., 62., 72., 53., 65., 42., 54.,
60., 79., 34., 58., 53., 57., 73., 102., 98.,
116., 136., 147., 107., 106., 124., 47., 91., 52.,
42., 16., 4., 7., 7., 6., 18., 44., 853., 216.])
我尝试更改高斯模型,但没有成功。也尝试过其他库。对正在发生的事情有什么想法吗?
最佳答案
我不熟悉lmfit包,但是来自documentation我认为您不应该在绘图中使用 result.init_fit
,而应该使用 result.best_fit
。
来自文档:
result.init_fit
模型函数的 numpy.ndarray 结果,根据提供的自变量和初始参数进行评估。
结果.best_fit
模型函数的 numpy.ndarray 结果,根据提供的自变量和最佳拟合参数进行评估。
关于Python - lmfit 不适合我的数据部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48612108/
我正在制作一个简单的程序来更改我的计算机背景。我在网上发现了一个stackoverflow问题,或多或少涵盖了我想做的事情。我现在可以成功地将我的墙纸更改为平铺、居中和从在线图像 URL 拉伸(str
是的,这是另一个每组最大的问题之一!我已经尝试了几天,试图解决这个问题,但无济于事。我也一直在寻找,但我什至不知道我是否在正确的地方寻找。问题的最简化版本如下。 我有 2 个表,一个是多对多表,另一个
我想解析一些数据,我有一个 BNF 语法来解析它。谁能推荐任何能够生成可在移动设备上使用的代码的语法编译器? 由于这是针对 JavaME 的,因此生成的代码必须是: 希望很小 对外来 Java 库的依
我有一个动物园时间序列对象,vels : 2011-05-01 00:00:00 7.52 2011-05-01 00:10:00 7.69 2011-05-01 00:20:00 7.67 2011
我想创建一个供小型制造公司使用的生产管理系统。该系统将允许记录设备制造的不同阶段。要求如下: 1.非基于浏览器的界面。需要基于 Swing 或 AWT 的东西。虽然我了解实现基于浏览器的解决方案的便利
是否有任何 java 或 clojure 邮件库可以实现 lamson 的功能?特别是lamson的邮件路由功能非常酷http://verpa.wordpress.com/2010/11/13/mak
sklearn 中的 fit() 方法似乎在同一界面中服务于不同的目的。 应用于训练集时,像这样: model.fit(X_train, y_train) fit() 用于学习稍后将在测试集上使用 p
我使用 OSM 显示县的边界。它在大多数情况下工作得很好,但在某些情况下,县更大并且不适合 map 。 如何在开始渲染之前调整缩放级别? var map = L.map("mapCnty").setV
我正在致力于缩小和丑化我的 javascript 文件。我想知道合适的尺寸是多大。如果我将所有js文件合并成一个文件(经过缩小和丑化),它会大于1mb。我想,最好将它们分成 2-3 个文件(每个文件
我是 Java 新手。 我想在 GridPane 中放置一个 TextArea。我在过去几个小时内尝试了此操作,结果如下: 如您所见,TextArea 比我的 Gridpane 大得多。这是我的代码:
sklearn 中的 fit() 方法似乎在同一界面中服务于不同的目的。 应用于训练集时,像这样: model.fit(X_train, y_train) fit() 用于学习稍后将在测试集上使用 p
我认为这是一个基本问题,但也许我混淆了这些概念。 假设我使用 R forecast 包中的函数 auto.arima() 将 ARIMA 模型拟合到时间序列。该模型假设方差不变。我如何获得该方差?是残
我使用 OSM 显示县的边界。它在大多数情况下工作得很好,但在某些情况下,县更大并且不适合 map 。 如何在开始渲染之前调整缩放级别? var map = L.map("mapCnty").setV
我有一个很长的标签,这是我的第一个标签,我想把它放在我的单元格中。这就是我所拥有的,但它不起作用。 我有一个自定义的 UITabelviewCell ,里面有几个标签。 -(CGFloat)table
假设我有一个包含 WCS header 的 FITS 文件,这样我就可以执行以下操作: #import healpy as hp #import astropy.io.fits as pyfits #
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎与 help center 中定义的范围内的编程无关。 . 已关闭10 年前。 Improve
我们正在构建一个与其他系统有多个集成接触点的应用程序。我们有效地使用 Unity 来满足我们所有的依赖注入(inject)需求。整个业务层是用接口(interface)驱动的方法构建的,实际实现在应用
我得到了 MKMapView 和一些注释。我使用下一个代码来显示所有注释: NSArray *coordinates = [self.mapView valueForKeyPath:@"annotat
我在一家托管公司工作,我们经常收到安装、新域、滞后修复等方面的请求。为了大致了解仍然开放的内容,我决定制作一个非常简单的票务系统。我有一点 php 知识和一点 MySQL 知识。目前,我们将根据客户的
我想向我的 UITableView 添加背景图像,它适合 UI,还具有导航 Controller 和工具栏。在那种情况下,我没有找到适合 iPhone 和 iPad 不同屏幕的 tableview 的
我是一名优秀的程序员,十分优秀!