An Exponential random variate
    
    Parameters
    ----------
    lamda : scalar
        The inverse scale (as shown on Wikipedia). (FYI: mu = 1/lamda.)
773944
def Exponential(lamda, tag=None):
    
    assert lamda > 0, 'Exponential "lamda" must be greater than zero'
    return uv(ss.expon(scale=1.0 / lamda), tag=tag)
260661
def posterior(self, x, Sigma=None):
        
        n = x.shape[0]
        Sigma = np.eye(self.dim) if Sigma is None else Sigma
        Siginv = inv(Sigma)
        Qpost = inv(self.cov) + n * Siginv
        Sigpost = inv(Qpost)
        mupost = (np.matmul(Siginv, self.mean) + 
                  np.matmu(Siginv, np.sum(x, axis=0)))
        return MvNormal(loc=mupost, cov=Sigpost)
1054304
def mse(mean, estimator):
    
    return np.mean((np.asarray(estimator) - np.asarray(mean)) ** 2, axis=0)
1184514
def proximal(self):
        

        if self.scalar < 0:
            raise ValueError('proximal operator of functional scaled with a '
                             'negative value {} is not well-defined'
                             ''.format(self.scalar))

        elif self.scalar == 0:
            # Should not get here. `Functional.__rmul__` takes care of the case
            # scalar = 0
            return proximal_const_func(self.domain)

        else:
            def proximal_left_scalar_mult(sigma=1.0):
                """Proximal operator for left scalar multiplication.

                    Parameters
                    ----------
                    sigma : positive float, optional
                        Step size parameter. Default: 1.0
                """
                return self.functional.proximal(sigma * self.scalar)

            return proximal_left_scalar_mult
369490
public SDVariable batchNorm(SDVariable input, SDVariable mean,
                                SDVariable variance, SDVariable gamma,
                                SDVariable beta, double epsilon, int... axis) {
        return batchNorm(null, input, mean, variance, gamma, beta, true, true, epsilon, axis);
    }
1267366
def _sample_orthonormal_to(mu):
    """"""
    v = np.random.randn(mu.shape[0])
    proj_mu_v = mu * np.dot(mu, v) / np.linalg.norm(mu)
    orthto = v - proj_mu_v
    return orthto / np.linalg.norm(orthto)
1366165
def exponential(x, y, xscale, yscale):
    
    if xscale==0.0 or yscale==0.0:
        return x*0.0

    with float_error_ignore():
        x_w = np.divide(x,xscale)
        y_h = np.divide(y,yscale)
        return np.exp(-np.sqrt(x_w*x_w+y_h*y_h))
559073
def random_orthonormal(normal):
    """"""
    u = normal_fns[np.argmin(np.fabs(normal))](normal)
    u /= np.linalg.norm(u)
    v = np.cross(normal, u)
    v /= np.linalg.norm(v)
    alpha = np.random.uniform(0.0, np.pi*2)
    return np.cos(alpha)*u + np.sin(alpha)*v
784164
def get_empirical_ar_params(train_datas, params):
    
    assert isinstance(train_datas, list) and len(train_datas) > 0
    datadimension = train_datas[0].shape[1]
    assert params["nu_0"] > datadimension + 1

    # Initialize the observation parameters
    obs_params = dict(nu_0=params["nu_0"],
                      S_0=params['S_0'],
                      M_0=params['M_0'],
                      K_0=params['K_0'],
                      affine=params['affine'])


    # Fit an AR model to the entire dataset
    obs_distn = AutoRegression(**obs_params)
    obs_distn.max_likelihood(train_datas)

    # Use the inferred noise covariance as the prior mean
    # E_{IW}[S] = S_0 / (nu_0 - datadimension - 1)
    obs_params["S_0"] = obs_distn.sigma * (params["nu_0"] - datadimension - 1)
    obs_params["M_0"] = obs_distn.A.copy()

    return obs_params
741590
def Kdiag(self, X):
        """"""
        K_ff = np.ones(X.shape[0])
        for i,x in enumerate(X):
            for il,l in enumerate(self.lengthscale):
                idx = il*2
                K_ff[i] *= self.k_ff(x[idx],x[idx],l)
        return K_ff * self.variances[0]
747260
def rlognormal(mu, tau, size=None):
    

    return np.random.lognormal(mu, np.sqrt(1. / tau), size)
674713
def gaussian1(height, x0, y0, a, b, c):
    

    return lambda x, y: height * np.exp(-0.5* (a*(x-x0)**2 + b*(x-x0)*(y-y0) + c*(y-y0)**2))
1185109
def scalar(cls, value):
    """"""
    return lambda i, name: cls(i, name, (value,), lambda a: a[0], None)
35910
def _fully_random_weights(n_features, lam_scale, prng):
    """"""
    weights = np.zeros((n_features, n_features))
    n_off_diag = int((n_features ** 2 - n_features) / 2)
    weights[np.triu_indices(n_features, k=1)] = 0.1 * lam_scale * prng.randn(
        n_off_diag
    ) + (0.25 * lam_scale)
    weights[weights < 0] = 0
    weights = weights + weights.T
    return weights
901307
def d_distributionparams(self):
        """"""
        if not self._d_distributionparams:
            dx = 1.0e-3
            def f_alpha(alpha):
                return DiscreteGamma(alpha, self.beta_lambda, self.ncats)
            def f_beta(beta):
                return DiscreteGamma(self.alpha_lambda, beta, self.ncats)
            assert set(self.distributionparams) == {'alpha_lambda', 'beta_lambda'}
            for (param, f) in [('alpha_lambda', f_alpha), ('beta_lambda', f_beta)]:
                pvalue = getattr(self, param)
                dparam = scipy.misc.derivative(f, pvalue, dx, n=1, order=5)
                assert dparam.shape == (self.ncats,)
                for stepchange in [0.5, 2]: # make sure robust to step size
                    dparam2 = scipy.misc.derivative(f, pvalue, stepchange * dx,
                            n=1, order=5)
                    assert scipy.allclose(dparam, dparam2, atol=1e-5, rtol=1e-4), (
                            "Numerical derivative of {0} at {1} "
                            "differs for step {2} and {3}: {4} and {5}"
                            ", respectively.").format(param, pvalue,
                            dx, dx * stepchange, dparam, dparam2)
                self._d_distributionparams[param] = dparam
        return self._d_distributionparams
675731
def bayesianUpperLimit(self, alpha, steps=1.e5, plot=False):
        
        x_dense, y_dense = self.densify()
        y_dense -= np.max(y_dense) # Numeric stability
        f = scipy.interpolate.interp1d(x_dense, y_dense, kind='linear')
        x = np.linspace(0., np.max(x_dense), steps)
        pdf = np.exp(f(x) / 2.)
        cut = (pdf / np.max(pdf)) > 1.e-10
        x = x[cut]
        pdf = pdf[cut]
        #pdf /= pdf[0]
        #forbidden = np.nonzero(pdf < 1.e-10)[0]
        #if len(forbidden) > 0:
        #    index = forbidden[0] # Numeric stability
        #    x = x[0: index]
        #    pdf = pdf[0: index]
        cdf = np.cumsum(pdf)
        cdf /= cdf[-1]
        cdf_reflect = scipy.interpolate.interp1d(cdf, x)

        return cdf_reflect(alpha)
401963
public RandomVariable[]	getParameter() {
		double[] parameterAsDouble = this.getParameterAsDouble();
		RandomVariable[] parameter = new RandomVariable[parameterAsDouble.length];
		for(int i=0; i<parameter.length; i++) {
			parameter[i] = new Scalar(parameterAsDouble[i]);
		}
		return parameter;
	}