Gets - \lambda * |\theta|_1.
341890
@Override
    public double getValue(IntDoubleVector params) {
        double sum = 0.0;
        for (int i=0; i<numParams; i++) {
            sum += Math.abs(params.get(i));
        }
        return - lambda * sum;
    }
518482
public static double poissonPDFm1(double x_plus_1, double lambda) {
    if(Double.isInfinite(lambda)) {
      return 0.;
    }
    if(x_plus_1 > 1) {
      return rawProbability(x_plus_1 - 1, lambda);
    }
    if(lambda > Math.abs(x_plus_1 - 1) * MathUtil.LOG2 * Double.MAX_EXPONENT / 1e-14) {
      return FastMath.exp(-lambda - GammaDistribution.logGamma(x_plus_1));
    }
    else {
      return rawProbability(x_plus_1, lambda) * (x_plus_1 / lambda);
    }
  }
248662
def calc_freefree_kappa(ne, t, hz):
    """"""
    return 9.78e-3 * ne**2 * hz**-2 * t**-1.5 * (24.5 + np.log(t) - np.log(hz))
1003681
def v_theta(self):
        
        # compute theta
        norm = np.sqrt(np.sum(self.wxyz**2))
        theta = 2 * np.arccos(self.wxyz[0] / norm)

        # compute the unit vector
        v = np.array(self.wxyz[1:])
        v = v / np.sqrt(np.sum(v**2))

        return v, theta
1134453
def from_v_theta(cls, v, theta):
        
        theta = np.asarray(theta)
        v = np.asarray(v)

        s = np.sin(0.5 * theta)
        c = np.cos(0.5 * theta)
        vnrm = np.sqrt(np.sum(v * v))

        q = np.concatenate([[c], s * v / vnrm])
        return cls(q)
210128
def node_theta(nodelist, node):
    
    assert len(nodelist) > 0, "nodelist must be a list of items."
    assert node in nodelist, "node must be inside nodelist."

    i = nodelist.index(node)
    theta = -np.pi + i * 2 * np.pi / len(nodelist)

    return theta
1344356
def _get_nsymop(self):
        """"""
        if self.centrosymmetric:
            return 2 * len(self._rotations) * len(self._subtrans)
        else:
            return len(self._rotations) * len(self._subtrans)
1072159
def _F(self, X):
        
        if isinstance(X, int) or isinstance(X, float):
            if X < 1 and X > 0:
                a = 1/(X**2-1)*(1-2/np.sqrt(1-X**2)*np.arctanh(np.sqrt((1-X)/(1+X))))
            elif X == 1:
                a = 1./3
            elif X > 1:
                a = 1/(X**2-1)*(1-2/np.sqrt(X**2-1)*np.arctan(np.sqrt((X-1)/(1+X))))
            else:  # X == 0:
                c = 0.0000001
                a = 1/(-1)*(1-2/np.sqrt(1)*np.arctanh(np.sqrt((1-c)/(1+c))))

        else:
            a = np.empty_like(X)
            x = X[(X < 1) & (X > 0)]
            a[(X < 1) & (X > 0)] = 1/(x**2-1)*(1-2/np.sqrt(1-x**2)*np.arctanh(np.sqrt((1-x)/(1+x))))

            a[X == 1] = 1./3.

            x = X[X > 1]
            a[X > 1] = 1/(x**2-1)*(1-2/np.sqrt(x**2-1)*np.arctan(np.sqrt((x-1)/(1+x))))
            # a[X>y] = 0

            c = 0.0000001
            a[X == 0] = 1/(-1)*(1-2/np.sqrt(1)*np.arctanh(np.sqrt((1-c)/(1+c))))
        return a
73572
public double getTheta() {
		double theta = StrictMath.toDegrees(StrictMath.atan2(y, x));
		if ((theta < -360) || (theta > 360)) {
			theta = theta % 360;
		}
		if (theta < 0) {
			theta = 360 + theta;
		}

		return theta;
	}
622769
def _get_I(self, a, b, size, plus_transpose=True):
        
        r_sum = np.zeros((3, 3), dtype='double', order='C')
        for r in self._rotations_cartesian:
            for i in range(3):
                for j in range(3):
                    r_sum[i, j] += r[a, i] * r[b, j]
        if plus_transpose:
            r_sum += r_sum.T

        # Return None not to consume computer for diagonalization
        if (np.abs(r_sum) < 1e-10).all():
            return None

        # Same as np.kron(np.eye(size), r_sum), but writen as below
        # to be sure the values in memory C-congiguous with 'double'.
        I_mat = np.zeros((3 * size, 3 * size), dtype='double', order='C')
        for i in range(size):
            I_mat[(i * 3):((i + 1) * 3), (i * 3):((i + 1) * 3)] = r_sum

        return I_mat
228652
def Gamma(k, theta, tag=None):
    
    assert (
        k > 0 and theta > 0
    ), 'Gamma "k" and "theta" parameters must be greater than zero'
    return uv(ss.gamma(k, scale=theta), tag=tag)
157439
def numdiff(fun, args):
    """"""

    # vectorized version

    epsilon = 1e-8
    args = list(args)
    v0 = fun(*args)
    N = v0.shape[0]
    l_v = len(v0)
    dvs = []
    for i, a in enumerate(args):
        l_a = (a).shape[1]
        dv = numpy.zeros((N, l_v, l_a))
        nargs = list(args)  #.copy()
        for j in range(l_a):
            xx = args[i].copy()
            xx[:, j] += epsilon
            nargs[i] = xx
            dv[:, :, j] = (fun(*nargs) - v0) / epsilon
        dvs.append(dv)
    return [v0] + dvs
963802
def find_lt(a, x):
    """"""
    i = bs.bisect_left(a, x)
    if i: return i - 1
    raise ValueError
1034431
public static double cdf(double val, double k, double lambda, double theta) {
    return (val > theta) ? //
        (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) //
        : val == val ? 0.0 : Double.NaN;
  }
7367
def l2norm_squared(a):
    
    value = 0
    for i in xrange(a.shape[1]):
        value += np.dot(a[:,i],a[:,i])
    return value
555311
def canorth(S):
    ""
    E,U = np.linalg.eigh(S)
    for i in range(len(E)):
        U[:,i] = U[:,i] / np.sqrt(E[i])
    return U
1237628
def obfn_reg(self):
        
        """
        l1 = np.sum(mp_wl1*np.abs(self.obfn_gvar()))
        return (self.lmbda*l1, l1)