def kstest_normal(x, pvalmethod='approx'):
 x = np.asarray(x)
 z = ((x - x.mean()) / x.std(ddof=1))
 nobs = len(z)
 d_ks = ksstat(z, stats.norm.cdf, alternative='two_sided')
 if (pvalmethod == 'approx'):
  pval = pval_lf(d_ks, nobs)
 elif (pvalmethod == 'table'):
  pval = lilliefors_table.prob(d_ks, nobs)
 return (d_ks, pval)

def kstest_normal ( x , pvalmethod = 'approx' ) : x = np . asarray ( x ) z = ( ( x - x . mean ( ) ) / x . std ( ddof = 1 ) ) nobs = len ( z ) d_ks = ksstat ( z , stats . norm . cdf , alternative = 'two_sided' ) if ( pvalmethod == 'approx' ) : pval = pval_lf ( d_ks , nobs ) elif ( pvalmethod == 'table' ) : pval = lilliefors_table . prob ( d_ks , nobs ) return ( d_ks , pval )
lilliefors test for normality .