def generalized_exponential(theta, d):
 theta = np.asarray(theta, dtype=np.float64)
 d = np.asarray(d, dtype=np.float64)
 if (d.ndim > 1):
  n_features = d.shape[1]
 else:
  n_features = 1
 lth = theta.size
 if ((n_features > 1) and (lth == 2)):
  theta = np.hstack([np.repeat(theta[0], n_features), theta[1]])
 elif (lth != (n_features + 1)):
  raise Exception(('Length of theta must be 2 or %s' % (n_features + 1)))
 else:
  theta = theta.reshape(1, lth)
 td = (theta[:, 0:(-1)].reshape(1, n_features) * (np.abs(d) ** theta[:, (-1)]))
 r = np.exp((- np.sum(td, 1)))
 return r

def generalized_exponential ( theta , d ) : theta = np . asarray ( theta , dtype = np . float64 ) d = np . asarray ( d , dtype = np . float64 ) if ( d . ndim > 1 ) : n_features = d . shape [ 1 ] else : n_features = 1 lth = theta . size if ( ( n_features > 1 ) and ( lth == 2 ) ) : theta = np . hstack ( [ np . repeat ( theta [ 0 ] , n_features ) , theta [ 1 ] ] ) elif ( lth != ( n_features + 1 ) ) : raise Exception ( ( 'Length of theta must be 2 or %s' % ( n_features + 1 ) ) ) else : theta = theta . reshape ( 1 , lth ) td = ( theta [ : , 0 : ( - 1 ) ] . reshape ( 1 , n_features ) * ( np . abs ( d ) ** theta [ : , ( - 1 ) ] ) ) r = np . exp ( ( - np . sum ( td , 1 ) ) ) return r
generalized exponential correlation model .