def tukeylambda_variance(lam):
 lam = np.asarray(lam)
 shp = lam.shape
 lam = np.atleast_1d(lam).astype(np.float64)
 threshold = 0.075
 low_mask = (lam < (-0.5))
 neghalf_mask = (lam == (-0.5))
 small_mask = (np.abs(lam) < threshold)
 reg_mask = (~ ((low_mask | neghalf_mask) | small_mask))
 small = lam[small_mask]
 reg = lam[reg_mask]
 v = np.empty_like(lam)
 v[low_mask] = np.nan
 v[neghalf_mask] = np.inf
 if (small.size > 0):
  v[small_mask] = (_tukeylambda_var_p(small) / _tukeylambda_var_q(small))
 if (reg.size > 0):
  v[reg_mask] = ((2.0 / (reg ** 2)) * ((1.0 / (1.0 + (2 * reg))) - beta((reg + 1), (reg + 1))))
 v.shape = shp
 return v

def tukeylambda_variance ( lam ) : lam = np . asarray ( lam ) shp = lam . shape lam = np . atleast_1d ( lam ) . astype ( np . float64 ) threshold = 0.075 low_mask = ( lam < ( - 0.5 ) ) neghalf_mask = ( lam == ( - 0.5 ) ) small_mask = ( np . abs ( lam ) < threshold ) reg_mask = ( ~ ( ( low_mask | neghalf_mask ) | small_mask ) ) small = lam [ small_mask ] reg = lam [ reg_mask ] v = np . empty_like ( lam ) v [ low_mask ] = np . nan v [ neghalf_mask ] = np . inf if ( small . size > 0 ) : v [ small_mask ] = ( _tukeylambda_var_p ( small ) / _tukeylambda_var_q ( small ) ) if ( reg . size > 0 ) : v [ reg_mask ] = ( ( 2.0 / ( reg ** 2 ) ) * ( ( 1.0 / ( 1.0 + ( 2 * reg ) ) ) - beta ( ( reg + 1 ) , ( reg + 1 ) ) ) ) v . shape = shp return v
variance of the tukey lambda distribution .