mogi.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:scikit-discovery 作者: MITHaystack 项目源码 文件源码
def FitPCA(self, hPCA_Proj):
        '''
        Determine the timing of the inflation event from the first component of the pca projection

        fits A * arctan( (t - t0) / c ) + B to the first pca projection, in order to estimate
        source amplitude parameters

        @param hPCA_Proj: The sklearn PCA 

        @return ct: the t0, c, and B parameters from the fit
        @return pA[0]: the fitted amplitude parameter
        '''

        fitfunc = lambda p,t: p[0]*np.arctan((t-p[1])/p[2])+p[3]
        errfunc = lambda p,x,y: fitfunc(p,x) - y

        dLen = len(hPCA_Proj[:,0])
        pA, success = optimize.leastsq(errfunc,[1.,dLen/2.,1.,0.],args=(np.arange(dLen),hPCA_Proj[:,0]))
        ct = pA[1:3]

        return ct, pA[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号