Implementation for single alpha value.

@param pi    The vector with probabilities.
@param a     The alpha parameter for all pseudocounts.
@return      The probability
19997
public static double dirichletPdf(double[] pi, double a) {
        double probability=1.0;
        
        int piLength=pi.length;
        
        for(int i=0;i<piLength;++i) {
            probability*=Math.pow(pi[i], a-1);
        }
        
        double sumAi=piLength*a;
        double productGammaAi=Math.pow(gamma(a), piLength);
        probability*=gamma(sumAi)/productGammaAi;
        
        return probability;
    }
1215720
public static double geometric(int k, double p) {
        if(k<=0 || p<0) {
            throw new IllegalArgumentException("All the parameters must be positive.");
        }
        
        double probability = Math.pow(1-p,k-1)*p;
        
        return probability;
    }
256028
public static float normalizeAngle (float a) {
        while (a < -FloatMath.PI) {
            a += TWO_PI;
        }
        while (a >= FloatMath.PI) {
            a -= TWO_PI;
        }
        return a;
    }
778839
public static void divide( DMatrix3 a , double alpha ) {
        a.a1 /= alpha;
        a.a2 /= alpha;
        a.a3 /= alpha;
    }
929281
def _sigma_pi_hiE(self, Tp, a):
        
        m_p = self._m_p
        csip = (Tp - 3.0) / m_p
        m1 = a[0] * csip ** a[3] * (1 + np.exp(-a[1] * csip ** a[4]))
        m2 = 1 - np.exp(-a[2] * csip ** 0.25)
        multip = m1 * m2
        return self._sigma_inel(Tp) * multip
654660
public static ComplexDoubleMatrix geru(ComplexDouble alpha, ComplexDoubleMatrix x,
			ComplexDoubleMatrix y, ComplexDoubleMatrix a) {
		NativeBlas.zgeru(a.rows, a.columns, alpha, x.data, 0, 1, y.data, 0, 1, a.data,
				0, a.rows);
		return a;
	}
114757
def _alpha_eff(self, r_eff, n_sersic, k_eff):
        
        b = self.b_n(n_sersic)
        alpha_eff = n_sersic * r_eff * k_eff * b**(-2*n_sersic) * np.exp(b) * special.gamma(2*n_sersic)
        return -alpha_eff
227785
public static boolean cholU( DMatrix5x5 A ) {

        A.a11 = Math.sqrt(A.a11);
        A.a21 = 0;
        A.a31 = 0;
        A.a41 = 0;
        A.a51 = 0;
        A.a12 = (A.a12)/A.a11;
        A.a22 = Math.sqrt(A.a22-A.a12*A.a12);
        A.a32 = 0;
        A.a42 = 0;
        A.a52 = 0;
        A.a13 = (A.a13)/A.a11;
        A.a23 = (A.a23-A.a12*A.a13)/A.a22;
        A.a33 = Math.sqrt(A.a33-A.a13*A.a13-A.a23*A.a23);
        A.a43 = 0;
        A.a53 = 0;
        A.a14 = (A.a14)/A.a11;
        A.a24 = (A.a24-A.a12*A.a14)/A.a22;
        A.a34 = (A.a34-A.a13*A.a14-A.a23*A.a24)/A.a33;
        A.a44 = Math.sqrt(A.a44-A.a14*A.a14-A.a24*A.a24-A.a34*A.a34);
        A.a54 = 0;
        A.a15 = (A.a15)/A.a11;
        A.a25 = (A.a25-A.a12*A.a15)/A.a22;
        A.a35 = (A.a35-A.a13*A.a15-A.a23*A.a25)/A.a33;
        A.a45 = (A.a45-A.a14*A.a15-A.a24*A.a25-A.a34*A.a35)/A.a44;
        A.a55 = Math.sqrt(A.a55-A.a15*A.a15-A.a25*A.a25-A.a35*A.a35-A.a45*A.a45);
        return !UtilEjml.isUncountable(A.a55);
    }
943640
public static void scale( double alpha , DMatrix3 a ) {
        a.a1 *= alpha;
        a.a2 *= alpha;
        a.a3 *= alpha;
    }
400872
public static double magnitude(@javax.annotation.Nonnull final double[] a) {
    return Math.sqrt(com.simiacryptus.util.ArrayUtil.dot(a, a));
  }
784488
public static void premultiply(int[] p, int offset, int length) {
		length += offset;
		for (int i = offset; i < length; i++) {
			int rgb = p[i];
			int a = (rgb >> 24) & 0xff;
			int r = (rgb >> 16) & 0xff;
			int g = (rgb >> 8) & 0xff;
			int b = rgb & 0xff;
			float f = a * (1.0f / 255.0f);
			r *= f;
			g *= f;
			b *= f;
			p[i] = (a << 24) | (r << 16) | (g << 8) | b;
		}
	}
585463
public static Color[] jet(int n, float alpha) {
        int m = (int) Math.ceil(n / 4);

        float[] u = new float[3 * m];
        for (int i = 0; i < u.length; i++) {
            if (i == 0) {
                u[i] = 0.0f;
            } else if (i <= m) {
                u[i] = i / (float) m;
            } else if (i <= 2 * m - 1) {
                u[i] = 1.0f;
            } else {
                u[i] = (3 * m - i) / (float) m;
            }

        }

        int m2 = m / 2 + m % 2;
        int mod = n % 4;
        int[] r = new int[n];
        int[] g = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < u.length - 1; i++) {
            if (m2 - mod + i < n) {
                g[m2 - mod + i] = i + 1;
            }
            if (m2 - mod + i + m < n) {
                r[m2 - mod + i + m] = i + 1;
            }
            if (i > 0 && m2 - mod + i < u.length) {
                b[i] = m2 - mod + i;
            }
        }

        Color[] palette = new Color[n];
        for (int i = 0; i < n; i++) {
            palette[i] = new Color(u[r[i]], u[g[i]], u[b[i]], alpha);
        }

        return palette;
    }
1222701
public static int alphaMixColors(int backgroundColor, int foregroundColor) {
		final byte ALPHA_CHANNEL = 24;
		final byte RED_CHANNEL = 16;
		final byte GREEN_CHANNEL = 8;
		final byte BLUE_CHANNEL = 0;

		final double ap1 = (double) (backgroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
		final double ap2 = (double) (foregroundColor >> ALPHA_CHANNEL & 0xff) / 255d;
		final double ap = ap2 + (ap1 * (1 - ap2));

		final double amount1 = (ap1 * (1 - ap2)) / ap;
		final double amount2 = amount1 / ap;

		int a = ((int) (ap * 255d)) & 0xff;

		int r = ((int) (((float) (backgroundColor >> RED_CHANNEL & 0xff) * amount1) +
				((float) (foregroundColor >> RED_CHANNEL & 0xff) * amount2))) & 0xff;
		int g = ((int) (((float) (backgroundColor >> GREEN_CHANNEL & 0xff) * amount1) +
				((float) (foregroundColor >> GREEN_CHANNEL & 0xff) * amount2))) & 0xff;
		int b = ((int) (((float) (backgroundColor & 0xff) * amount1) +
				((float) (foregroundColor & 0xff) * amount2))) & 0xff;

		return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
	}
566501
protected static double GammaCdf(double x, double a) throws IllegalArgumentException
    {
        if (x < 0)
        {
            throw new IllegalArgumentException();
        }

        double GI = 0;
        if (a > 200)
        {
            double z = (x - a) / Math.sqrt(a);
            double y = GaussCdf(z);
            double b1 = 2 / Math.sqrt(a);
            double phiz = 0.39894228 * Math.exp(-z * z / 2);
            double w = y - b1 * (z * z - 1) * phiz / 6;  //Edgeworth1
            double b2 = 6 / a;
            int zXor4 = ((int) z) ^ 4;
            double u = 3 * b2 * (z * z - 3) + b1 * b1 * (zXor4 - 10 * z * z + 15);
            GI = w - phiz * z * u / 72;        //Edgeworth2
        }
        else if (x < a + 1)
        {
            GI = Gser(x, a);
        }
        else
        {
            GI = Gcf(x, a);
        }

        return GI;
    }
118723
def _get_asym_alpha(self,a,b):
        
        
        # just  use AL0
        try:
            a = a[2:4]
        except IndexError:
            a = a[:2]
            
        # sum counts in alpha detectors
        asum = np.sum(a,axis=0)
        
        # sum counts in beta detectors
        bsum = np.sum(b,axis=0)
        
        # check for dividing by zero 
        asum[asum == 0] = np.nan
        bsum[bsum == 0] = np.nan
        
        # asym calcs
        asym = asum/bsum
        
        # errors
        dasym = asym*np.sqrt(1/asum + 1/bsum)
        
        return [asym,dasym]
416500
public static IntDoubleVector getRandomBernoulliDirection(int p) {
        IntDoubleVector e = new IntDoubleDenseVector(p);
        for (int i=0; i<p; i++) {
            // Bernoulli distribution chooses either positive or negative 1.
            e.set(i, (Prng.nextBoolean()) ? 1 : -1);
        }
        return e;
    }
739691
public static int changeColorAlpha(int color, int alpha) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        return alpha << 24 | r << 16 | g << 8 | b;
    }