Exemple #1
0
def c2uhat(c, returnSingleVector=False):
    ''' Transform unconstrained variable c into constrained uhat

      Returns
      --------
      uhat : 1D array, size K, entries between [0, 1]
  '''
    uhat = sigmoid(c)
    return uhat
def c2rhoomega(c, returnSingleVector=False):
    ''' Transform unconstrained variable c into constrained rho, omega

    Returns
    --------
    rho : 1D array, size K, entries between [0, 1]
    omega : 1D array, size K, positive entries

    OPTIONAL: may return as one concatenated vector (length 2K)
    '''
    K = c.size / 2
    rho = sigmoid(c[:K])
    omega = np.exp(c[K:])
    if returnSingleVector:
        return np.hstack([rho, omega])
    return rho, omega
def c2rho(c):
    return sigmoid(c)