A Poisson random variate
    
    Parameters
    ----------
    lamda : scalar
        The rate of an occurance within a specified interval of time or space.
768484
def Poisson(lamda, tag=None):
    
    assert lamda > 0, 'Poisson "lamda" must be greater than zero.'
    return uv(ss.poisson(lamda), tag=tag)
1209509
def Random(self):
        
        p = numpy.random.gamma(self.params)
        return p / p.sum()
883858
def kurtosis(data):
    

    if not data:
        raise StatisticsError('kurtosis requires at least one data point')

    size = len(data)
    sd = stdev(data) ** 4

    if not sd:
        return 0.0

    mn = mean(data)
    return sum(map(lambda x: ((x - mn) ** 4 / sd), data)) / size - 3
575390
private RandomVariable getShortRate(int timeIndex) throws CalculationException {
		double time = getProcess().getTime(timeIndex);
		double timePrev = timeIndex > 0 ? getProcess().getTime(timeIndex-1) : time;
		double timeNext = getProcess().getTime(timeIndex+1);

		RandomVariable zeroRate = getZeroRateFromForwardCurve(time); //getDiscountFactorFromForwardCurve(time).div(getDiscountFactorFromForwardCurve(timeNext)).log().div(timeNext-time);

		RandomVariable alpha = getDV(0, time);

		RandomVariable value = getProcess().getProcessValue(timeIndex, 0);
		value = value.add(alpha);
		//		value = value.sub(Math.log(value.exp().getAverage()));

		value = value.add(zeroRate);

		return value;
	}
1031010
def disasters(value=disasters_array, params_of_mean=params_of_mean):
    """"""
    val = params_of_mean[1] + params_of_mean[0] * arange(111)
    return poisson_like(value, val)
1285380
def step_random_processes(oscillators):
    
    if not rand.prob_bool(0.01):
        return
    amp_bias_weights = [(0.001, 1), (0.1, 100), (0.15, 40), (1, 0)]
    # Find out how many oscillators should move
    num_moves = iching.get_hexagram('NAIVE') % len(oscillators)
    for i in range(num_moves):
        pair = [gram % len(oscillators)
                for gram in iching.get_hexagram('THREE COIN')]
        amplitudes = [(gram / 64) * rand.weighted_rand(amp_bias_weights)
                      for gram in iching.get_hexagram('THREE COIN')]
        oscillators[pair[0]].amplitude.drift_target = amplitudes[0]
        oscillators[pair[1]].amplitude.drift_target = amplitudes[1]
854952
public static void ge_double_scalarmult_vartime(ge_p2 r, byte[] a, ge_p3 A, byte[] b) {
        byte[] aslide = new byte[256];
        byte[] bslide = new byte[256];
        ge_cached Ai[] = new ge_cached[8]; /* A,3A,5A,7A,9A,11A,13A,15A */
        for (int count = 0; count < 8; count++)
            Ai[count] = new ge_cached();
        ge_p1p1 t = new ge_p1p1();
        ge_p3 u = new ge_p3();
        ge_p3 A2 = new ge_p3();
        int i;

        slide(aslide, a);
        slide(bslide, b);

        ge_p3_to_cached.ge_p3_to_cached(Ai[0], A);
        ge_p3_dbl.ge_p3_dbl(t, A);
        ge_p1p1_to_p3.ge_p1p1_to_p3(A2, t);
        ge_add.ge_add(t, A2, Ai[0]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[1], u);
        ge_add.ge_add(t, A2, Ai[1]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[2], u);
        ge_add.ge_add(t, A2, Ai[2]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[3], u);
        ge_add.ge_add(t, A2, Ai[3]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[4], u);
        ge_add.ge_add(t, A2, Ai[4]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[5], u);
        ge_add.ge_add(t, A2, Ai[5]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[6], u);
        ge_add.ge_add(t, A2, Ai[6]);
        ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
        ge_p3_to_cached.ge_p3_to_cached(Ai[7], u);

        ge_p2_0.ge_p2_0(r);

        for (i = 255; i >= 0; --i) {
            if (aslide[i] != 0 || bslide[i] != 0) break;
        }

        for (; i >= 0; --i) {
            ge_p2_dbl.ge_p2_dbl(t, r);

            if (aslide[i] > 0) {
                ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
                ge_add.ge_add(t, u, Ai[aslide[i] / 2]);
            } else if (aslide[i] < 0) {
                ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
                ge_sub.ge_sub(t, u, Ai[(-aslide[i]) / 2]);
            }

            if (bslide[i] > 0) {
                ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
                ge_madd.ge_madd(t, u, Bi[bslide[i] / 2]);
            } else if (bslide[i] < 0) {
                ge_p1p1_to_p3.ge_p1p1_to_p3(u, t);
                ge_msub.ge_msub(t, u, Bi[(-bslide[i]) / 2]);
            }

            ge_p1p1_to_p2.ge_p1p1_to_p2(r, t);
        }
    }
1097799
def pstdev(data):
        """"""
        n = len(data)
        if n < 2:
            return 0
            # raise ValueError('variance requires at least two data points')
        ss = TableExtraction._ss(data)
        pvar = ss/n # the population variance
        return pvar**0.5
1184571
def sde(self): 
         
        
        variance = float(self.variance.values)
        lengthscale = float(self.lengthscale.values)

        lamda = np.sqrt(5.0)/lengthscale
        kappa = 5.0/3.0*variance/lengthscale**2        
        
        F = np.array(((0, 1,0), (0, 0, 1), (-lamda**3, -3.0*lamda**2, -3*lamda)))
        L = np.array(((0,),(0,),(1,)))
        Qc = np.array((((variance*400.0*np.sqrt(5.0)/3.0/lengthscale**5),),))
        H = np.array(((1,0,0),))        
        
        Pinf = np.array(((variance,0,-kappa), (0, kappa, 0), (-kappa, 0, 25.0*variance/lengthscale**4)))
        P0 = Pinf.copy()
        # Allocate space for the derivatives         
        dF = np.empty((3,3,2))        
        dQc = np.empty((1,1,2))        
        dPinf = np.empty((3,3,2))
        
         # The partial derivatives 
        dFvariance = np.zeros((3,3))
        dFlengthscale = np.array(((0,0,0),(0,0,0),(15.0*np.sqrt(5.0)/lengthscale**4, 
                                   30.0/lengthscale**3, 3*np.sqrt(5.0)/lengthscale**2)))
        dQcvariance = np.array((((400*np.sqrt(5)/3/lengthscale**5,),)))
        dQclengthscale = np.array((((-variance*2000*np.sqrt(5)/3/lengthscale**6,),)))        
        
        dPinf_variance = Pinf/variance
        kappa2 = -2.0*kappa/lengthscale
        dPinf_lengthscale = np.array(((0,0,-kappa2),(0,kappa2,0),(-kappa2, 
                                    0,-100*variance/lengthscale**5)))        
        # Combine the derivatives 
        dF[:,:,0] = dFvariance
        dF[:,:,1] = dFlengthscale        
        dQc[:,:,0] = dQcvariance         
        dQc[:,:,1] = dQclengthscale        
        dPinf[:,:,0] = dPinf_variance
        dPinf[:,:,1] = dPinf_lengthscale
        dP0 = dPinf.copy()
        
        return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0)
1209201
def _rndPointDisposition(dx, dy):
        """"""
        x = int(random.uniform(-dx, dx))
        y = int(random.uniform(-dy, dy))
        return (x, y)
612686
function createRandom(n, min, max) {
    let scale = max - min;
    let array = [];
    for (var i = 0; i < n; i++) {
        array[i] = (Math.random() * scale) + min;
    }
    return new Vector(array);
}
540252
private void doMutation(double probability, DoubleSolution solution) {
    double rnd, deltaq, tempDelta;
    double y, yl, yu;

    for (int i = 0; i < solution.getNumberOfVariables(); i++) {
      if (randomGenerator.nextDouble() <= probability) {
        y = solution.getVariableValue(i);
        yl = solution.getLowerBound(i) ;
        yu = solution.getUpperBound(i) ;
        rnd = randomGenerator.nextDouble();
          
        tempDelta = Math.pow(rnd, -delta);
        deltaq = 0.5 * (rnd - 0.5) * (1 - tempDelta);
          
        y = y + deltaq * (yu - yl);
        y = solutionRepair.repairSolutionVariableValue(y, yl, yu);
        solution.setVariableValue(i, y);
      }
    }
  }
604810
def fit_mle(self, data, init_vals=(80, 80)):
        

        if len(data) > 1:
            mu = np.mean(data)
            var = np.var(data)
            theta0 = var / mu
            alpha0 = mu / theta0
        else:
            alpha0 = init_vals[0]
            theta0 = init_vals[1]

        def mle(params):
            return -np.sum(np.log(self.pmf(data, params[0], params[1])))

        # Bounded fmin?
        alpha, theta = optim.fmin(mle, x0=[alpha0, theta0], disp=0)

        return alpha, theta
642951
def Weibull(lamda, k, tag=None):
    
    assert (
        lamda > 0 and k > 0
    ), 'Weibull "lamda" and "k" parameters must be greater than zero'
    return uv(ss.exponweib(lamda, k), tag=tag)
1273401
def _random_weights(n_features, lam, lam_perturb, prng):
    
    weights = np.zeros((n_features, n_features))
    n_off_diag = int((n_features ** 2 - n_features) / 2)
    berns = prng.binomial(1, 0.5, size=n_off_diag)
    vals = np.zeros(berns.shape)
    vals[berns == 0] = 1. * lam * lam_perturb
    vals[berns == 1] = 1. * lam / lam_perturb
    weights[np.triu_indices(n_features, k=1)] = vals
    weights[weights < 0] = 0
    weights = weights + weights.T
    return weights
900282
def zip_ll_row(params, data_row):
    
    l = params[0]
    pi = params[1]
    d0 = (data_row==0)
    likelihood = d0*pi + (1-pi)*poisson.pmf(data_row, l)
    return -np.log(likelihood+eps).sum()
780138
def _scalar_type_std_res(self, counts, total, colsum, rowsum):
        
        expected_counts = expected_freq(counts)
        residuals = counts - expected_counts
        variance = (
            np.outer(rowsum, colsum)
            * np.outer(total - rowsum, total - colsum)
            / total ** 3
        )
        return residuals / np.sqrt(variance)