def jarque_bera(resids, axis=0):
 resids = np.asarray(resids)
 skew = stats.skew(resids, axis=axis)
 kurtosis = (3 + stats.kurtosis(resids, axis=axis))
 n = resids.shape[axis]
 jb = ((n / 6.0) * ((skew ** 2) + ((1 / 4.0) * ((kurtosis - 3) ** 2))))
 jb_pv = stats.chi2.sf(jb, 2)
 return (jb, jb_pv, skew, kurtosis)

def jarque_bera ( resids , axis = 0 ) : resids = np . asarray ( resids ) skew = stats . skew ( resids , axis = axis ) kurtosis = ( 3 + stats . kurtosis ( resids , axis = axis ) ) n = resids . shape [ axis ] jb = ( ( n / 6.0 ) * ( ( skew ** 2 ) + ( ( 1 / 4.0 ) * ( ( kurtosis - 3 ) ** 2 ) ) ) ) jb_pv = stats . chi2 . sf ( jb , 2 ) return ( jb , jb_pv , skew , kurtosis )
perform the jarque-bera goodness of fit test on sample data .