python 高斯函数拟合,使用Python将指数修正的高斯曲线拟合到数据

本文探讨了如何使用Python对数据进行指数修正的高斯曲线拟合。通过scipy.optimize.curve_fit函数尝试拟合样本数据,但发现拟合结果与数据不匹配。作者对数据进行了反转操作,以解决可能的偏斜问题,但未详细说明最终的拟合效果。
摘要由CSDN通过智能技术生成

I have a data set and a kernel density estimate for those data. I believe the KDE should be reasonably well described by an exponentinally modified Gaussian, so I'm trying to sample from the KDE and fit those samples with a function of that type. However, when I try to fit using scipy.optimize.curve_fit, my fit doesn't match the data well at all. My code is

import scipy.special as sse

from scipy.optimize import curve_fit

def fit_func(x, l, s, m):

return 0.5*l*n.exp(0.5*l*(2*m+l*s*s-2*x))*sse.erfc((m+l*s*s-x)/(n.sqrt(2)*s)) # exponential gaussian

popt, pcov = curve_fit(fit_func, n.linspace(0,1,100), data)

My "data set" (from sampling my KDE) is

data = [1.00733940e-09, 1.36882036e-08, 1.44555907e-07, 1.18647634e-06, 7.56926695e-06, 3.75417381e-05, 1.44836578e-04, 4.35259159e-04, 1.02249858e-03, 1.89480681e-03, 2.83

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值