• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python stattools.durbin_watson函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中statsmodels.stats.stattools.durbin_watson函数的典型用法代码示例。如果您正苦于以下问题:Python durbin_watson函数的具体用法?Python durbin_watson怎么用?Python durbin_watson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了durbin_watson函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_durbin_watson

def test_durbin_watson():
    #benchmark values from R car::durbinWatsonTest(x)
    #library("car")
    #> durbinWatsonTest(x)
    #[1] 1.95298958377419
    #> durbinWatsonTest(x**2)
    #[1] 1.848802400319998
    #> durbinWatsonTest(x[2:20]+0.5*x[1:19])
    #[1] 1.09897993228779
    #> durbinWatsonTest(x[2:20]+0.8*x[1:19])
    #[1] 0.937241876707273
    #> durbinWatsonTest(x[2:20]+0.9*x[1:19])
    #[1] 0.921488912587806
    st_R = 1.95298958377419
    assert_almost_equal(durbin_watson(x), st_R, 14)

    st_R = 1.848802400319998
    assert_almost_equal(durbin_watson(x**2), st_R, 14)

    st_R = 1.09897993228779
    assert_almost_equal(durbin_watson(x[1:]+0.5*x[:-1]), st_R, 14)

    st_R = 0.937241876707273
    assert_almost_equal(durbin_watson(x[1:]+0.8*x[:-1]), st_R, 14)

    st_R = 0.921488912587806
    assert_almost_equal(durbin_watson(x[1:]+0.9*x[:-1]), st_R, 14)
开发者ID:Code-fish,项目名称:statsmodels,代码行数:27,代码来源:test_statstools.py


示例2: checkdb

def checkdb(df,col):
    "It also tells whether the Data is serially correlated or not "
    r = k.durbin_watson(df[col], axis=0)
    if(r==0):
        print "Not Serially correlated "
        return False,r
    else:
        print "Serially correlated "
        return True,r
开发者ID:tannishk,项目名称:data-profiling,代码行数:9,代码来源:timeseries.py


示例3: fit

def fit(y, X, reg_names):
    nr = len(reg_names)
    
    try:
        mod = sm.GLSAR(y.values, X, 2, missing = 'drop') # MLR analysis with AR2 modeling
        res = mod.iterative_fit()
        output = xr.Dataset({'coef': (['reg_name'], res.params[1:]), \
                'conf_int': (['reg_name', 'limit'], res.conf_int()[1:,:]), \
                'p_value': (['reg_name'],  res.pvalues[1:]), \
                'DWT': (sms.durbin_watson(res.wresid)), \
                'CoD': (res.rsquared)}, \
                coords = {'reg_name': (['reg_name'], reg_names),\
                          'limit': (['limit'], ['lower', 'upper'])})
    except: 
        nans = np.full([nr], np.nan)
        output = xr.Dataset({'coef': (['reg_name'], nans), \
                'conf_int': (['reg_name', 'limit'], np.array([nans, nans]).T), \
                'p_value': (['reg_name'],  nans), \
                'DWT': (np.nan), \
                'CoD': (np.nan)}, \
                coords = {'reg_name': (['reg_name'], reg_names),\
                          'limit': (['limit'], ['lower', 'upper'])})

    return output
开发者ID:kuchaale,项目名称:X-regression,代码行数:24,代码来源:lin_reg_univ_ccmi_xarray.py


示例4: test_durbin_watson_3d

 def test_durbin_watson_3d(self):
     shape = (10, 1, 10)
     x = np.random.standard_normal(100)
     dw = sum(np.diff(x)**2.0) / np.dot(x, x)
     x = np.tile(x[None, :, None], shape)
     assert_almost_equal(np.squeeze(dw * np.ones(shape)), durbin_watson(x, axis=1))
开发者ID:dieterv77,项目名称:statsmodels,代码行数:6,代码来源:test_statstools.py


示例5: test_durbin_watson

 def test_durbin_watson(self):
     x = np.random.standard_normal(100)
     dw = sum(np.diff(x)**2.0) / np.dot(x, x)
     assert_almost_equal(dw, durbin_watson(x))
开发者ID:dieterv77,项目名称:statsmodels,代码行数:4,代码来源:test_statstools.py


示例6: test_durbin_watson_pandas

def test_durbin_watson_pandas():
    x = np.random.randn(50)
    x_series = pd.Series(x)
    assert_almost_equal(durbin_watson(x), durbin_watson(x_series), decimal=13)
开发者ID:dieterv77,项目名称:statsmodels,代码行数:4,代码来源:test_statstools.py


示例7: fitdata


#.........这里部分代码省略.........
    
    res = scipy.optimize.leastsq(error, pguess, args=(Xdata, Ydata, Errdata, dict_data), full_output=1)
    (popt, pcov, infodict, errmsg, ier) = res
    perr=scipy.sqrt(scipy.diag(pcov))
    
    M=len(Ydata)
    N=len(popt)
    #Residuals
    Y=f(Xdata,popt,dict_data)
    residuals=(Y-Ydata)/Errdata
    meanY=scipy.mean(Ydata)
    squares=(Y-meanY)/Errdata
    squaresT=(Ydata-meanY)/Errdata
    
    SSM=sum(squares**2) #Corrected Sum of Squares
    SSE=sum(residuals**2) #Sum of Squares of Errors
    SST=sum(squaresT**2) #Total corrected sum of squares
    
    DFM=N-1 #Degrees of freedom for model
    DFE=M-N #Degrees of freedom for error
    DFT=M-1 #Degrees of freedom total
    
    MSM=SSM/DFM #Mean squares for model (explained variance)
    MSE=SSE/DFE #Mean squares for Error (should be small wrt MSM) Unexplained Variance
    MST=SST/DFT #Mean squares for total
    
    R2=SSM/SST #proportion of explained variance
    R2_adj=1-(1-R2)*(M-1)/(M-N-1) #Adjusted R2
    
    #t-test to see if parameters are different from zero
    t_stat=popt/perr #t-statistic for popt different from zero'
    t_stat=t_stat.real
    p_p=1.0-scipy.stats.t.cdf(t_stat,DFE) #should be low for good fit.
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    #Chisquared Analysis on Residuals
    chisquared=sum(residuals**2)
    degfreedom=M-N
    chisquared_red=chisquared/degfreedom
    p_chi2=1.0-scipy.stats.chi2.cdf(chisquared,degfreedom)
    stderr_reg=scipy.sqrt(chisquared_red)
    chisquare=(p_chi2,chisquared, chisquared_red, degfreedom,R2,R2_adj)
    
    #Analysis of Residuals
    w,p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals)
    stddev_res=scipy.sqrt(scipy.var(residuals))
    t_res=mean_res/stddev_res #t-statistic to test that mean_res is zero.
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
        #if p_res <0.05, null hypothesis rejected and mean is non-zero.
        #Should be high for good fit.
    #F-test on residuals
    F=MSM/MSE #explained variance/unexplained . Should be large
    p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
        #if p_F <0.05n, null-hypothesis is rejected
        #i.e. R^2>0 and at least one of the fitting parameters >0.
    dw=stools.durbin_watson(residuals)
    resanal=(p_shapiro,w,mean_res,F,p_F,dw)
    
    
    
    if ax:
        formataxis(ax)
        ax.plot(Ydata,Y,'ro')
        ax.errorbar(Ydata,Y,yerr=Errdata,fmt='.')
        Ymin,Ymax=min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        
        sigmay,avg_stddev_data=get_stderr_fit(f,Xdata,popt,pcov,dict_data)
        Yplus=Y+sigmay
        Yminus=Y-sigmay
        ax.plot(Y,Yplus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.plot(Y,Yminus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.fill_between(Y,Yminus,Yplus,facecolor='cyan',alpha=0.5)
        titletext='Parity plot for fit.\n'
        titletext+=r'$r^2$=%5.2f, $r^2_{adj}$=%5.2f, '
        titletext +='$\sigma_{exp}$=%5.2f,$\chi^2_{\nu}$=%5.2f, $p_{\chi^2}$=%5.2f, '
        titletext +='$\sigma_{err}^{reg}$=%5.2f'
        
        ax.title.set_text(titletext%(R2,R2_adj, avg_stddev_data, chisquared_red,  p_chi2, stderr_reg))
        ax.figure.canvas.draw()
        
    if ax2:#Test for homoscedasticity
        formataxis(ax2)
        ax2.plot(Y,residuals,'ro')
        
        ax2.xaxis.label.set_text('Fitted Data')
        ax2.yaxis.label.set_text('Residuals')
        
        titletext='Analysis of Residuals\n'
        titletext+=r'mean=%5.2f, $p_{res}$=%5.2f, $p_{shapiro}$=%5.2f, $Durbin-Watson$=%2.1f'
        titletext+='\nF=%5.2f, $p_F$=%3.2e'
        ax2.title.set_text(titletext%(mean_res, p_res, p_shapiro, dw , F, p_F))
        
        ax2.figure.canvas.draw()
        
    return popt,pcov,perr,p95,p_p,chisquare,resanal
开发者ID:sparshganju,项目名称:psl_sem6_ict,代码行数:101,代码来源:error_estimation.py


示例8: test_frame_timeseries_durbin_watson

    def test_frame_timeseries_durbin_watson(self):
        """Test Durbin Watson"""
        result = self.frame.timeseries_durbin_watson_test("logM")
        db_result = smst.durbin_watson(self.pandaframe["logM"])

        self.assertAlmostEqual(result, db_result, delta=0.0000000001)
开发者ID:Haleyo,项目名称:spark-tk,代码行数:6,代码来源:frame_timeseries_test.py


示例9: fitdata

def fitdata(f,Xdata,Ydata,Errdata,pguess,ax= False,ax2= False):
    
    #calculating the popt 
    
    def error(pguess,Xdata,Ydata,Errdata):
        Y=f(Xdata,pguess)
        residuals= (Y-Ydata)/Errdata
        return (residuals)
    
    res= scipy.optimize.leastsq(error, pguess,args=(Xdata,Ydata,Errdata),full_output=1)
      
    (popt,pcov,infodict,errmsg,ier)=res
      
    perr= scipy.sqrt(scipy.diag(pcov))
    
    M= len(Xdata)
    N= len(popt)
   #residuals
    Y= f(Xdata,popt)
    residuals=(Y-Ydata)/Errdata
    meanY= scipy.mean(Ydata)
    squares= (Y-meanY)/Errdata
    squaresT= (Ydata-meanY)/Errdata
    
    SSM= sum(squares**2)#corrected sum of squares
    SSE= sum(residuals**2)#sum of squares of errors
    SST= sum(squaresT**2)#total corrected sum of squrare

    DFM= N-1
    DFE= M-N
    DFT= M-1

    MSM= SSM/DFM
    MSE= SSE/DFE
    MST= SST/DFT

    R2= SSM/SST    #proportion of explained variance
    R2_adj= 1-(1-R2)*(M-1)/(M-N-1)#Adjusted R2 

    # t test to see if parameters are different from 0
    t_stat= popt/perr
    t_stat= t_stat.real
    p_p= 1.0-scipy.stats.t.cdf(t_stat,DFE)
    z=scipy.stats.t(M-N).ppf(0.95)
    p95= perr*z

    #chisquared analysis on residuals
    chisquared= sum(residuals**2)
    degfreedom= M-N
    chisquared_red= chisquared/degfreedom
    p_chi2= 1.0-scipy.stats.chi2.cdf(chisquared,degfreedom)       
    stderr_reg= scipy.sqrt(chisquared_red)
    chisquare=(p_chi2, chisquared,chisquared_red,degfreedom,R2,R2_adj)
    
    #analysis of residuals
    w,p_shapiro= scipy.stats.shapiro(residuals)
    mean_res= scipy.mean(residuals)
    stddev_res= scipy.sqrt(scipy.var(residuals))
    t_res= mean_res/stddev_res 
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
    #if p<0.05, null hypothesis is rejected and mean is non-zero
    #should be high for a good fit
    
    #F-test on the residuals
    F= MSM/MSE #explained variance/ unexplained should be large
    p_F= 1.0-scipy.stats.f.cdf(F,DFM,DFE)
    #if p_F<0.05, null hypo is rejected
    dw= stools.durbin_watson(residuals)
    resanal= (p_shapiro,w,mean_res,p_res,F,p_F,dw)
    
    if ax:
        formataxis(ax)
        ax.plot(Ydata,Y,'ro')
        ax.errorbar(Ydata,Y,yerr=Errdata,fmt='.')
        Ymin, Ymax= min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        
        sigmaY, avg_stddev_data= get_stderr_fit(f,Xdata,popt,pcov)
        Yplus= Y+sigmaY
        Yminus= Y-sigmaY
        ax.plot(Y,Yplus,'c',alpha=0.6,linestyle='--',linewidth= 0.5)
        ax.plot(Y,Yminus,'c',alpha=0.6,linestyle='--',linewidth= 0.5)
        ax.fill_between(Y,Yminus,Yplus,facecolor= 'cyan',alpha=0.5)
        titletext='Parity plot for fit.\n'
        titletext+= r'$r^r$=%5.2f,$r^2_(adj)$=%5.2f,'
        titletext+= '$\sigma_<exp>$=%5.2f,$\chi^2_<\nu>$= %5.2f,$p_<chi_2>$=%5.2f,'
        titletext+= '$sigma_<err>^<reg>$=%5.2f'
        
        ax.title.set_text(titletext%(R2,R2_adj,avg_stddev_data,chisquared_red,p_chi2,stderr_reg))
        ax.figure.canvas.draw()
        
    if ax2 :  #test for homoscedaticity  
        formataxis(ax2)
        ax2.plot(Y,residuals,'ro')
        
        ax2.xaxis.label.set_text('Fitted Data')
        ax2.yaxis.label.set_text('Residuals')
#.........这里部分代码省略.........
开发者ID:OmkarMehta,项目名称:Endsem_final,代码行数:101,代码来源:Error_estimation.py


示例10: fitdata

def fitdata(f,Xdata,Ydata,Errdata,pguess,ax=False,ax2=False):
	'''
	fitdata(f,Xdata,Ydata,Errdata,pguess):
	'''
	def error(p,Xdata,Ydata,Errdata):
		Y=f(Xdata,p)
		residuals=(Y-Ydata)/Errdata
		return residuals
	res=scipy.optimize.leastsq(error,pguess,args=(Xdata,Ydata,Errdata),full_output=1)
	(popt,pcov,infodict,errmsg,ier)=res   #optimize p
	perr=scipy.sqrt(scipy.diag(pcov))    #vector of sd of p
	M=len(Ydata)
	N=len(popt)
	#Residuals
	Y=f(Xdata,popt)
	residuals=(Y-Ydata)/Errdata
	meanY=scipy.mean(Ydata)
	squares=(Y-meanY)/Errdata
	squaresT=(Ydata-meanY)/Errdata
	
	SSM=sum(squares**2) #corrected sum of squares
	SSE=sum(residuals**2)  #sum of squares of errors
	SST=sum(squaresT**2)  #total corrected sum of squares
	
	DFM=N-1   #for model
	DFE=M-N   #for error
	DFT=M-1   #total
	
	MSM=SSM/DFM #mean squares for model(explained variance)
	MSE=SSE/DFE #mean squares for errors(should be small wrt MSM) unexplained variance
	MST=SST/DFT #mean squares for total	
	
	R2=SSM/SST  #proportion of explained variance
	R2_adj=1-(1-R2)*(M-1)/(M-N-1) #adjusted R2
	
	#ttest to see if parameters are different from zero
	t_stat=popt/perr #tstatistic for popt different from zero
	t_stat=t_stat.real
	p_p=1.0-scipy.stats.t.cdf(t_stat,DFE) #should be low for good fit
	z=scipy.stats.t(M-N).ppf(0.95)
	p95=perr*z
	#Chisquared ananlysis on residuals
	chisquared=sum(residuals**2)
	degfreedom=M-N
	chisquared_red=chisquared/degfreedom
	p_chi2=1.0-scipy.stats.chi2.cdf(chisquared,degfreedom)
	stderr_reg=scipy.sqrt(chisquared_red)
	chisquare=(p_chi2,chisquared,chisquared_red,degfreedom,R2,R2_adj)
	
	#Analysis of residuals
	w,p_shapiro=scipy.stats.shapiro(residuals) # to check if residuals are normally distributed
	mean_res=scipy.mean(residuals)
	stddev_res=scipy.sqrt(scipy.var(residuals))
	t_res=mean_res/stddev_res
	p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
	#if p_res<0.05,null hypothesis is rejected.
	#R^2>0 and at least one of the fitting parameters>0
	#F-test on residuals
	F=MSM/MSE
	p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
	
	dw=stools.durbin_watson(residuals) #to check if they are correlated
	resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)
	
	if ax:
		formataxis(ax)
		ax.plot(Ydata,Y,'ro')
		ax.errorbar(Ydata,Y,yerr=Errdata,fmt='.')
		Ymin,Ymax=min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
		ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
		
		ax.xaxis.label.set_text('Data')
		ax.yaxis.label.set_text('Fitted')
		sigmay,avg_stddev_data=get_stderr_fit(f, Xdata, popt, pcov)
		Yplus=Y+sigmay
		Yminus=Y-sigmay
		ax.plot(Y,Yplus,'c',alpha=.6,linestyle='--',linewidth=.5)
		ax.plot(Y,Yminus,'c',alpha=.6,linestyle='--',linewidth=.5)
		ax.fill_between(Y,Yminus,Yplus,facecolor='cyan',alpha=.5)
		titletext='Parity plot for fit.\n'
		titletext+=r'$r^2$=%5.2f,$r^2_{adj}$=%5.2f, '
		titletext+='$\sigma_{exp}$=%5.2f,$\chi^2_{\nu}$=%5.2f,$p_{\chi^2}$=%5.2f, '
		titletext+='$\sigma_{err}^{reg}$=%5.2f'
		ax.title.set_text(titletext%(R2,R2_adj,avg_stddev_data,chisquared_red,p_chi2,stderr_reg))
		ax.figure.canvas.draw()
	
	if ax2:#test for homoscedasticity
		formataxis(ax2)
		ax2.plot(Y,residuals,'ro')
		
		ax2.xaxis.label.set_text('Fitted data')
		ax2.yaxis.label.set_text('Residuals')
		
		titletext='Analysis of residuals\n'
		titletext+=r'mean=%5.2f,$p_{res}$=%5.2f,$p_{shapiro}$=%5.2f,$Durbin-Watson$=%2.1f'
		titletext+='\n F=%5.2f,$p_F$=%3.2e'
		ax2.title.set_text(titletext%(mean_res,p_res,p_shapiro,dw,F,p_F))
		
		ax2.figure.canvas.draw()
		
#.........这里部分代码省略.........
开发者ID:OmkarMehta,项目名称:Endsem_final,代码行数:101,代码来源:errorestimation_tutorial.py


示例11: test_durbin_watson_2d

 def test_durbin_watson_2d(self, reset_randomstate):
     shape = (1, 10)
     x = np.random.standard_normal(100)
     dw = sum(np.diff(x)**2.0) / np.dot(x, x)
     x = np.tile(x[:, None], shape)
     assert_almost_equal(np.squeeze(dw * np.ones(shape)), durbin_watson(x))
开发者ID:ChadFulton,项目名称:statsmodels,代码行数:6,代码来源:test_statstools.py


示例12: qqplot

sunspot_data = sm.datasets.sunspots.load_pandas().data
sunspot_data.index = pd.Index(sm.tsa.datetools.dates_from_range('1700', '2008'))
del sunspot_data["YEAR"]

sunspot_data.plot(figsize=(12,8));

fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(211)
fig = sm.graphics.tsa.plot_acf(sunspot_data.values.squeeze(), lags=40, ax=ax1)
ax2 = fig.add_subplot(212)
fig = sm.graphics.tsa.plot_pacf(sunspot_data, lags=40, ax=ax2)

arma_mod20 = sm.tsa.ARMA(sunspot_data, (2,0)).fit()
arma_mod30 = sm.tsa.ARMA(sunspot_data, (3,0)).fit()

stattools.durbin_watson(arma_mod30.resid.values)

fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
ax = arma_mod30.resid.plot(ax=ax)

resid = arma_mod30.resid

diag.normal_ad(resid)

fig = plt.figure(figsize=(12,8))
ax = fig.add_subplot(111)
fig = qqplot(resid, line='q', ax=ax, fit=True)

fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(211)
开发者ID:herrGagen,项目名称:sandbox,代码行数:31,代码来源:sunspots.py


示例13: fitdata

def fitdata(f,Xdata,Ydata,Errdata,pguess,dict_data,ax=False,ax2=False):
    
    def error(p,Xdata,Ydata,Errdata,dict_data):
        Y=f(Xdata,p,dicct_data)
        residuals=(Y-Ydata)/Errdata
        return residuals
    res=scipy.optimize.leastsq(error,pguess.args=(Xdata,Ydata,Errdata,dict_data),full_output=1)
    (popt,pcov,infodict,errmsg,ier)=res
    perr=scipy.sqrt(scipy.diag(pcov))
    
    M=len(Ydata)
    N=len(popt)
    
    Y=f(Xdata,popt,dict_data)
    residuals=(Y-Ydata)/Errdata
    meanY=scipy.mean(Ydata)
    squares=(Y-meanY)/Errdata
    squaresT=(Ydata-meanY)/Errdata
    
    SSM=sum(squares**2)
    SSE=sum(residuals**2)
    SST=sum(squaresT**2)
    
    DFM=N-1
    DFE=M-N
    DFT=M-1
    
    MSM=SSM/DFM
    MSE=SSE/DFE
    MST=SST/DFT
    
    R2=SSM/SST
    R2_adj=1-(1-R2)*(M-1)/(M-N-1)
    
    t_stat=popt/perr
    t_stat=t_stat.real
    p_p=1.0-scipy.stats.t.cdf(t_stat,DFE)
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    
    chisquared=sum(residuals**2)
    degfreeedom=M-N
    chisqured_red=chisquared/degfreedom
    p_chi2=1.0-scipy.stats.chi2.cdf(chisquared,degfreedom)
    chisquare=(p_chi2,chisquared,chisquared_red,degfreedom,R2,R2_adj)
    
    w,p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals)
    stddev_res=scipy.sqrt(scipy.var(residuals))
    t_res=mean_res/stddev_res
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
    
    F=MSM/MSE
    p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
    
    dw=stools.durbin_watson(residuals)
    resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)
    
    if ax:
        formataxis(ax)
        ax.plotdata(Ydata,Y,'ro')
        ax.errorbar(Ydata,Y,yerr=Errdata,fmt='.')
        Ymin,Ymax=min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        
        sigmay,avg_stddev_data=get_stderr_fit(f,Xdata,popt,pcov,dict_data)
        Yplus=Y+sigmay
        Yminus=Y-sigmay
        ax.plot(Y,Yplus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.plot(Y,Yminus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.fill_between(Y,Yminus,Yplus,facecolor='cyan',alpha=0.5)
        titletext ='parity plot for fit.\n'
        titletext +=r'$r^2$=%5.2f,$r^2_{adj}$=%5.2f,'
        titletext +='$\sigma_{exp}$=%5.2f,$\chi^2_{\nu}$=%5.2f,$p_{\chi^2}$=%5.2f,'
        titletext +='$\sigma_{err}^{reg}$=%5.2f'
        
        ax.title.set_text(titletext%(R2,R2_adj,avg_stddev_data,chisquared_red,p_chi2,stderr_reg))
        ax.figure.canvas.draw()
        
    if ax2:
        formataxis(ax2)
        ax2.plot(Y,residuals,'ro')
        
        ax2.xaxis.label.set_text('Fitted Data')
        ax2.yaxis.label.set_text('Residuals')
        
        titletext ='Analysis of Residuals\n'
        titletext +=r'mean=%5.2f,$p_{res}$=%5.2f,$p_{shapiro}$=%5.2f, $Durbin-Watson=%2.1f'
        titletext +='\n F=%5.2f, $p_F$=%3.2e'
        ax2.title.set_text(titletext%(mean_res,p_res,p_shapiro,dw,F,p_F))
        
        ax2.figure.canvas.draw()
        
    return popt,pcov,perr,p95,p_p,chisquare,resanal
开发者ID:vinitdedhiya,项目名称:project,代码行数:97,代码来源:erroranalysis.py


示例14: fitdata

def fitdata(f,Xdata,Ydata,Errdata,pguess,ax=False,ax2=False):

    def error(p,Xdata,Ydata,Errdata):
        Y=f(Xdata,p)
        residuals=(Y-Ydata)/Errdata
        return residuals
    res=scipy.optimize.leastsq(error,pguess,args=(Xdata,Ydata,Errdata),full_output=1)    
    (popt,pcov,infodict,errmsg,ier)=res
    perr=scipy.sqrt(scipy.diag(pcov))
    M=len(Ydata)
    N=len(popt)
    Y=f(Xdata,popt)
    residuals=(Y-Ydata)/Errdata
    meanY=scipy.mean(Ydata)
    squares=(Y-meanY)/Errdata
    squaresT=(Ydata-meanY)/Errdata
    
    SSM=sum(squares**2)
    SSE=sum(residuals**2)
    SST=sum(squaresT**2)
    
    DFM=N-1
    DFE=M-N
    DFT=M-1
    
    MSM=SSM/DFM
    MSE=SSE/DFE
    MSM=SST/DFT
    
    '''R2'''
    R2=SSM/SST
    R2_adj=1-(1-R2)*(M-1)/(M-N-1)
    
    '''t-test'''
    t_stat=popt/perr
    t_stat=t_stat.real
    p_p=1.0-scipy.stats.t.cdf(t_stat,DFE)
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    
    '''chi-square'''
    chisqred=sum(residuals**2)
    degfrdm=M-N
    chisqred_red=chisqred/degfrdm
    p_chi2=1.0-scipy.stats.chi2.cdf(chisqred,degfrdm)
    stderr_reg=scipy.sqrt(chisqred_red)
    chisqre=(p_chi2,chisqred,chisqred_red,degfrdm,R2,R2_adj)
    
    '''shapiro-wilk test'''
    w,p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals)
    stddev_res=scipy.sqrt(scipy.var(residuals))
    t_res=mean_res/stddev_res
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
    
    '''F-test'''
    F=MSM/MSE
    p_F=1-scipy.stats.f.cdf(F,DFM,DFE)
    
    '''durbin-watson'''
    dw=stools.durbin_watson(residuals)
    
    resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)

    return popt,pcov,perr,p95,p_p,chisqre,resanal,R2,chisqred,w,dw
开发者ID:sparshganju,项目名称:psl_sem6_ict,代码行数:65,代码来源:error1.2.py


示例15: int

        'F_Statistic': results.fvalue,
        'F_Statistic_P_Value': results.f_pvalue,
        'Log_Likelihood': results.llf,
        'AIC': results.aic,
        'BIC': results.bic,
        'Number_Of_Observations': int(results.nobs),
        'Degrees_Of_Freedom_Model': int(results.df_model),
        'Degrees_Of_Freedom_Residual': int(results.df_resid)
    },
    'Parameters': params,
    'Diagnostics': {
        'Omnibus': results.diagn['omni'],
        'Omnibus_P_Value': results.diagn['omnipv'],
        'Skew': results.diagn['skew'],
        'Kurtosis': results.diagn['kurtosis'],
        'Durbin_Watson': durbin_watson(results.wresid),
        'Jarque_Bera': results.diagn['jb'],
        'Jarque_Bera_P_Value': results.diagn['jbpv'],
        'Condition_Number': results.diagn['condno']
    }
}

print(json.dumps(resultsObject, sort_keys=True))


#                             OLS Regression Results                            
# ==============================================================================
# Dep. Variable:                   var1   R-squared:                       0.734
# Model:                            OLS   Adj. R-squared:                  0.706
# Method:                 Least Squares   F-statistic:                     26.21
# Date:                Sun, 05 Jul 2015   Prob (F-statistic):           3.45e-06
开发者ID:lee19840806,项目名称:Online-Stats,代码行数:31,代码来源:ols_regression.py


示例16: fitdata

def fitdata(f,XData,YData,ErrData,pguess,ax=False,ax2=False):
    
    def error(p,XData,YData,ErrData):
        Y=f(XData,p)
        residuals=(Y-YData)/ErrData
        return residuals
    res=scipy.optimize.leastsq(error,pguess,args=(XData,YData,ErrData),full_output=1)
    (popt,pcov,infodict,errmsg,ier)=res
    
    perr=scipy.sqrt(scipy.diag(pcov))
    
    M=len(YData)
    N=len(popt)
    #residuals
    Y=f(XData,popt)
    residuals=(Y-YData)/ErrData
    meanY=scipy.mean(YData)
    squares=(Y-meanY)/ErrData
    squaresT=(YData-meanY)/ErrData
    
    SSM=sum(squares**2) #Corrected Sum of Squares
    SSE=sum(residuals**2)#Sum of Squares of Errors
    SST=sum(squaresT**2)#Totaal corrected sum of squares
    
    DFM=N-1 #degrees of freedom for model
    DFE=M-N #degrees of freedom for error
    DFT=M-1 #degrees of freedom total
    
    MSM=SSM/DFM #Mean squares for model (explained variance)
    MSE=SSE/DFE #Mean squares for error
    MST=SST/DFT #Mean squares for total
    
    R2=SSM/SST #proportion of explained varience
    R2_adj=1-(1-R2)*(M-1)/(M-N-1)#Adjusted R2
    
    #t-test to see if parameters are different from zero
    t_stat=popt/perr #t-statistic for popt different from zero
    t_stat=t_stat.real
    p_p=1.0-scipy.stats.t.cdf(t_stat,DFE) #should be low for good fit.
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    
    #chisquared analysis on residuals
    chisquared=sum(residuals**2)
    degfreedom=M-N
    chisquared_red=chisquared/degfreedom
    p_chi2=1.0-scipy.stats.chi2.cdf(chisquared,degfreedom)
    stderr_reg=scipy.sqrt(chisquared_red)
    chisquare=(p_chi2,chisquared_red,degfreedom,R2,R2_adj)
    
    #Analysis of Residuals
    w,p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals) #mean of all residuals
    stddev_res=scipy.sqrt(scipy.var(residuals)) #standard deviation of all residuals
    t_res=mean_res/stddev_res #t-statistic to test that was mean_res is zero.
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
         #if p_res<0.05,null-hypothesis is rejected and mean is non-zero
         #should be high for good fit.
    # F-test on residuals
    F=MSM/MSE #explained/un-explained. Should be large
    p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
         #if p_F<0.05,null hypothesis is rejected
         #i.e. R^2>0 and at least one of the fitting parameters >0.
    dw=stools.durbin_watson(residuals)
    resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)
    if ax:
        formataxis(ax)
        ax.plot(YData,Y,'ro')
        ax.errorbar(YData,Y,yerr=ErrData,fmt='.')
        Ymin,Ymax=min((min(Y),min(YData))), max((max(Y),max(YData)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        
        sigmaY,avg_stddev_data=get_stderr_fit(f,XData,popt,pcov)
        Yplus=Y+sigmaY
        Yminus=Y-sigmaY
        ax.plot(Y,Yplus,'C',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.plot(Y,Yminus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.fill_between(Y,Yminus,Yplus,facecolor='cyan',alpha=0.5)
        titletext='Parity plot for fit.\n'
        titletext += r'$r^2$ = %5.2f, $r^2_(adj)$= %5.2f'
        titletext +='$\sigma_{exp}$ = %5.2f, $\chi^2_{\nu}$=%5.2f, $p_{\chi^2}$=%5.2f,'
        titletext +='$\sigma_{ree}^{reg}$ = %5.2f'
        
        ax.title.set_text(titletext%(R2,R2_adj,avg_stddev_data,chisquared_red,p_chi2,stderr_reg))
        ax.figure.canvas.draw()
        
    if ax2: #test for homoscedasticity
        formataxis(ax2)
        ax2.plot(Y,residuals,'ro')
        
        ax2.xaxis.label.set_text('Fitted Data')
        ax2.yaxis.label.set_text('Residuals')
        
        titletext = 'Analysis of residuals\n'
        titletext +=r'mean= %5.2f, $p_{res}$= %5.2f, $p_{shapiro}$=%5.2f , $Durbin-watson$=%2.1f'
        titletext +='\n F=%5.2f,$p_F$ = %3.2e'
        ax2.title.set_text(titletext%(mean_res,p_res,p_shapiro,dw,F,p_F))
#.........这里部分代码省略.........
开发者ID:tusharshende,项目名称:flash,代码行数:101,代码来源:error+analyis+static+mixer.py


示例17: summary

    def summary(self, yname=None, xname=None, title=None, alpha=.05):
        """Summarize the Regression Results

        Parameters
        -----------
        yname : string, optional
            Default is `y`
        xname : list of strings, optional
            Default is `var_##` for ## in p the number of regressors
        title : string, optional
            Title for the top table. If not None, then this replaces the
            default title
        alpha : float
            significance level for the confidence intervals

        Returns
        -------
        smry : Summary instance
            this holds the summary tables and text, which can be printed or
            converted to various output formats.

        See Also
        --------
        statsmodels.iolib.summary.Summary : class to hold summary
            results

        """

        #TODO: import where we need it (for now), add as cached attributes
        from statsmodels.stats.stattools import (jarque_bera,
                omni_normtest, durbin_watson)
        jb, jbpv, skew, kurtosis = jarque_bera(self.wresid)
        omni, omnipv = omni_normtest(self.wresid)

        eigvals = self.eigenvals
        condno = self.condition_number

        self.diagn = dict(jb=jb, jbpv=jbpv, skew=skew, kurtosis=kurtosis,
                          omni=omni, omnipv=omnipv, condno=condno,
                          mineigval=eigvals[0])

        top_left = [('Dep. Variable:', None),
                    ('Model:', None),
                    ('Method:', ['Least Squares']),
                    ('Date:', None),
                    ('Time:', None)
                    ]

        top_right = [('Pseudo R-squared:', ["%#8.4g" % self.prsquared]),
                     ('Bandwidth:', ["%#8.4g" % self.bandwidth]),
                     ('Sparsity:', ["%#8.4g" % self.sparsity]),
                     ('No. Observations:', None),
                     ('Df Residuals:', None), #[self.df_resid]), #TODO: spelling
                     ('Df Model:', None) #[self.df_model])
                    ]

        diagn_left = [('Omnibus:', ["%#6.3f" % omni]),
                      ('Prob(Omnibus):', ["%#6.3f" % omnipv]),
                      ('Skew:', ["%#6.3f" % skew]),
                      ('Kurtosis:', ["%#6.3f" % kurtosis])
                      ]

        diagn_right = [('Durbin-Watson:', ["%#8.3f" % durbin_watson(self.wresid)]),
                       ('Jarque-Bera (JB):', ["%#8.3f" % jb]),
                       ('Prob(JB):', ["%#8.3g" % jbpv]),
                       ('Cond. No.', ["%#8.3g" % condno])
                       ]


        if title is None:
            title = self.model.__class__.__name__ + ' ' + "Regression Results"

        #create summary table instance
        from statsmodels.iolib.summary import Summary
        smry = Summary()
        smry.add_table_2cols(self, gleft=top_left, gright=top_right,
                          yname=yname, xname=xname, title=title)
        smry.add_table_params(self, yname=yname, xname=xname, alpha=.05,
                             use_t=True)

#        smry.add_table_2cols(self, gleft=diagn_left, gright=diagn_right,
                          #yname=yname, xname=xname,
                          #title="")

        #add warnings/notes, added to text format only
        etext = []
        if eigvals[-1] < 1e-10:
            wstr = "The smallest eigenvalue is %6.3g. This might indicate "
            wstr += "that there are\n"
            wstr += "strong multicollinearity problems or that the design "
            wstr += "matrix is singular."
            wstr = wstr % eigvals[-1]
            etext.append(wstr)
        elif condno > 1000:  #TODO: what is recommended
            wstr = "The condition number is large, %6.3g. This might "
            wstr += "indicate that there are\n"
            wstr += "strong multicollinearity or other numerical "
            wstr += "problems."
            wstr = wstr % condno
            etext.append(wstr)
#.........这里部分代码省略.........
开发者ID:SuperXrooT,项目名称:statsmodels,代码行数:101,代码来源:quantile_regression.py


示例18: fitdata

def fitdata(f, Xdata,Ydata,Errdata, pguess,dict_data, ax=False, ax2=False):
    def error(p,Xdata,Ydata,Errdata,dict_data):
        Y=f(Xdata,p,dic_data)
        residuals=(Y-Ydata)/Errdata
    return residuals
    
    res=scipy.optimize.leastsq(error,pguess,args=(Xdata,Ydata,Errdata,dict_data),full_output=1)
    (popt,pcov,infodict,errmsg,ier)=res
    perr=scipy.sqrt(scipy.diag(pcov))

    M=len(Ydata)
    N=len(popt)
    #Residuals
    Y=f(Xdata,popt,dict_data)
    residuals=(Y-Ydata)/Errdata
    meanY=scipy.mean(Ydata)
    squares=(Y-meanY)/Errdata
    squaresT=(Ydata-meanY)/Errdata
    
    SSM=sum(squares**2) #Corrected Sum of Squares
    SSE=sum(residuals**2) #Sum of Squares of Errors
    SST=sum(squaresT**2)#Total Corrected sum of Squares
    
    DFM=N-1 #Degree of Freedom for model
    DFE=M-N #Degree of Freedom for error
    DFT=M-1 #Degree of freedom total
    
    MSM=SSM/DFM #Mean Squares for model(explained Variance)
    MSE=SSE/DFE #Mean Squares for Error(should be small wrt MSM) unexplained Variance
    MST=SST/DFT #Mean squares for total
    
    R2=SSM/SST #proportion of unexplained variance 
    R2_adj= 1-(1-R2)*(M-1)/(M-N-1) #Adjusted R2
    
    #t-test to see if parameters are different from zero
    t_stat=popt/perr #t-stat for popt different from zero
    t_stat=t_stat.real
    p_p= 1.0-scipy.stats.t.cdf(t_stat,DFE) #should be low for good fit
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    #Chi-Squared Analysis on Residuals
    chisquared=sum(residuals**2)
    degfreedom=M-N
    chisquared_red=chisquared/degfreedom
    p_chi2=1.0-scipy.stats.chi2.cdf(chisquared, degfreedom)
    stderr_reg=scipy.sqrt(chisquared_red)
    chisquare=(p_chi2,chisquared,chisquared_red,degfreedom,R2,R2_adj)
    
    #Analysis of Residuals
    w, p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals)
    stddev_res=scipy.sqrt(scipy.var(residuals))
    t_res=mean_res/stddev_res #t-statistics
    p_res=1.0-scipy.stats.cdf(t_res,M-1)
    
    F=MSM/MSE
    p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
    
    dw=stools.durbin_watson(residuals)
    resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)
    
    if ax:
        formataxis(ax)
        ax.plot(Ydata,Y,'ro')
        ax.errorbar(Ydata,Y,yerr=Errdata, fmt='.')
        Ymin,Ymax=min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        sigmay,avg_stddev_data=get_stderr_fit(f,xdata,popt,pcov,dict_data)
        Yplus=Y+sigmay
        Yminus=Y-sigmay
        ax.plot(Y,Yplus,'c',alpha=0.6,linestyle='--',linewidth=0.5)
        ax.plot(Y,Yminus,'c',alpha=0.6,linestyle='==',linewidth=0.5)
        ax.fill_between(Y,Yminus,Yplus,facecolor='cyan',alpha=0.5)
        titletext='Parity plot for fit.\n'
        titletext+=r'$r^2$=%5.2f,$r^2_{adj}$=%5.2f,$p_{shapiro}$=%5.2f,$Durbin-Watson=%2.1f'
        titletext+='\n F=%5.2f,$p_F$=%3.2e'
        titletext+='$\sigma_{err}^{reg}$=%5.2f'
        
        ax.title.set.text(titletext%(R2,R2_adj,avg_stddev_data,chisquared_red,p_chi2,stderr_reg))
        ax.figure.canvas.draw()
    
    if ax2:
        formataxis(ax2)
        ax2.plot(Y,residuals,'ro')
        ax2.xaxis.label.set_text('Fitted Data')
        ax2.yaxis.label.set_text('Residuals')
        
        titletext='Analysis of Residuals\n'
        titletext+=r'mean=%5.2f,$p_{res}$=%5.2f,$p_{shapiro}$=%5.2f,$Durbin-Watson$=%2.1f'
        titletext+='\n F=%5.2f,$p_F$=%3.2e'
        ax2.title.set_text(titletext%(mean_res,p_res,p_shapiro,dw,F,p_F))
    return popt,pcov,perr, p95, p_p,chisquare, resanal
开发者ID:mailrachitgupta,项目名称:tryout2,代码行数:95,代码来源:ErrorAnalysis.py


示例19: fitdata

def fitdata(f, Xdata,Ydata,Errdata, pguess, ax=False, ax2=False):
    '''
    popt = vector of length N of the optimized parameters
    pcov = Covariance matrix of the fit
    perr = vector of length N of the std-dev of the optimized parameters
    p95 = half width of the 95% confidence interval for each parameter 
    p_p = vector of length N of the p-value for the parameters being zero
    (if p<0.05, null hypothesis rejected and parameter is non-zero) 
    chisquared = chisquared value for the fit
    chisquared_red = chisquared/degfreedom
    chisquare = (p, chisquared, chisquared_red, degfreedom) 
    p = Probability of finding a chisquared value at least as extreme as the one shown
    chisquared_red = chisquared/degfreedom. value should be approx. 1 for a good fit. 
    R2 = correlation coefficient or proportion of explained variance 
    R2_adj = adjusted R2 taking into account number of predictors 
    resanal = (p, w, mean, stddev)
    Analysis of residuals 
    p = Probability of finding a w at least as extreme as the one observed (should be high for good fit) 
    w = Shapiro-Wilk test criterion 
    mean = mean of residuals 
    p_res = probability that the mean value obtained is different from zero merely by chance 
    F = F-statistic for the fit msm/msE. 
    Null hypothesis is that there is NO Difference between the two variances. 
    p_F = probability that this value of F can arise by chance alone.
    p_F < 0.05 to reject null hypothesis and prove that the fit is good.
    dw = Durbin_Watson statistic (value between 0 and 4). 
    2 = no-autocorrelation. 0 = .ve autocorrelation, 4 = -ve autocorrelation. 
'''    
    
    def error(p,Xdata,Ydata,Errdata):
        Y=f(Xdata,p)
        residuals=(Y-Ydata)/Errdata
        return residuals
    res=scipy.optimize.leastsq(error,pguess,args=(Xdata,Ydata,Errdata),full_output=1)
    (popt,pcov,infodict,errmsg,ier)=res
    perr=scipy.sqrt(scipy.diag(pcov))

    M=len(Ydata)
    N=len(popt)
    #Residuals
    Y=f(Xdata,popt)
    residuals=(Y-Ydata)/Errdata
    meanY=scipy.mean(Ydata)
    squares=(Y-meanY)/Errdata
    squaresT=(Ydata-meanY)/Errdata
    
    SSM=sum(squares**2) #Corrected Sum of Squares
    SSE=sum(residuals**2) #Sum of Squares of Errors
    SST=sum(squaresT**2)#Total Corrected sum of Squares
    
    DFM=N-1 #Degree of Freedom for model
    DFE=M-N #Degree of Freedom for error
    DFT=M-1 #Degree of freedom total
    
    MSM=SSM/DFM #Mean Squares for model(explained Variance)
    MSE=SSE/DFE #Mean Squares for Error(should be small wrt MSM) unexplained Variance
    MST=SST/DFT #Mean squares for total
    
    R2=SSM/SST #proportion of unexplained variance 
    R2_adj= 1-(1-R2)*(M-1)/(M-N-1) #Adjusted R2
    
    #t-test to see if parameters are different from zero
    t_stat=popt/perr #t-stat for popt different from zero
    t_stat=t_stat.real
    p_p= 1.0-scipy.stats.t.cdf(t_stat,DFE) #should be low for good fit
    z=scipy.stats.t(M-N).ppf(0.95)
    p95=perr*z
    #Chi-Squared Analysis on Residuals
    chisquared=sum(residuals**2)
    degfreedom=M-N
    chisquared_red=chisquared/degfreedom
    p_chi2=1.0-scipy.stats.chi2.cdf(chisquared, degfreedom)
    stderr_reg=scipy.sqrt(chisquared_red)
    chisquare=(p_chi2,chisquared,chisquared_red,degfreedom,R2,R2_adj)
    
    #Analysis of Residuals
    w, p_shapiro=scipy.stats.shapiro(residuals)
    mean_res=scipy.mean(residuals)
    stddev_res=scipy.sqrt(scipy.var(residuals))
    t_res=mean_res/stddev_res #t-statistics
    p_res=1.0-scipy.stats.t.cdf(t_res,M-1)
    
    F=MSM/MSE
    p_F=1.0-scipy.stats.f.cdf(F,DFM,DFE)
    
    dw=stools.durbin_watson(residuals)
    resanal=(p_shapiro,w,mean_res,p_res,F,p_F,dw)
    
    if ax:
        formataxis(ax)
        ax.plot(Ydata,Y,'ro')
        ax.errorbar(Ydata,Y,yerr=Errdata, fmt='.')
        Ymin,Ymax=min((min(Y),min(Ydata))),max((max(Y),max(Ydata)))
        ax.plot([Ymin,Ymax],[Ymin,Ymax],'b')
        
        ax.xaxis.label.set_text('Data')
        ax.yaxis.label.set_text('Fitted')
        sigmay,avg_stddev_data=get_stderr_fit(f,Xdata,popt,pcov)
        Yplus=Y+sigmay
        Yminus=Y-sigmay
#.........这里部分代码省略.........
开发者ID:Shubham55,项目名称:tryout5,代码行数:101,代码来源:error+analysis+1.py


示例20: fitdata

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_weightstats.Holder类代码示例发布时间:2022-05-27
下一篇:
Python sandwich_covariance.se_cov函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap