def theilslopes(y, x=None, alpha=0.95):
 y = ma.asarray(y).flatten()
 if (x is None):
  x = ma.arange(len(y), dtype=float)
 else:
  x = ma.asarray(x).flatten()
  if (len(x) != len(y)):
   raise ValueError(('Incompatible lengths ! (%s<>%s)' % (len(y), len(x))))
 m = ma.mask_or(ma.getmask(x), ma.getmask(y))
 y._mask = x._mask = m
 y = y.compressed()
 x = x.compressed().astype(float)
 return stats_theilslopes(y, x, alpha=alpha)

def theilslopes ( y , x = None , alpha = 0.95 ) : y = ma . asarray ( y ) . flatten ( ) if ( x is None ) : x = ma . arange ( len ( y ) , dtype = float ) else : x = ma . asarray ( x ) . flatten ( ) if ( len ( x ) != len ( y ) ) : raise ValueError ( ( 'Incompatible lengths ! (%s<>%s)' % ( len ( y ) , len ( x ) ) ) ) m = ma . mask_or ( ma . getmask ( x ) , ma . getmask ( y ) ) y . _mask = x . _mask = m y = y . compressed ( ) x = x . compressed ( ) . astype ( float ) return stats_theilslopes ( y , x , alpha = alpha )
computes the theil-sen estimator for a set of points .