Returns the cumulative probability of Uniform

@param x
@param a
@param b
@return
430510
public static double uniformCdf(double x, double a, double b) {
        if(a>=b) {
            throw new IllegalArgumentException("The a must be smaller than b.");
        }
        
        double probabilitySum;
        if(x<a) {
            probabilitySum=0.0;
        }
        else if(x<b) {
            probabilitySum=(x-a)/(b-a);
        }
        else {
            probabilitySum=1;
        }

        return probabilitySum;
    }
862790
public static float smoothStep(float a, float b, float x) {
		if (x < a)
			return 0;
		if (x >= b)
			return 1;
		x = (x - a) / (b - a);
		return x*x * (3 - 2*x);
	}
1369859
function randi(a, b) {
    return Math.floor(Math.random()*(b-a)+a);
}
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;
    }
102896
function ( vectorA, vectorB, vectorC ) {

		var a, b, c,
			point = new THREE.Vector3(),
			tmp = THREE.GeometryUtils.__v1;

		a = THREE.GeometryUtils.random();
		b = THREE.GeometryUtils.random();

		if ( ( a + b ) > 1 ) {

			a = 1 - a;
			b = 1 - b;

		}

		c = 1 - a - b;

		point.copy( vectorA );
		point.multiplyScalar( a );

		tmp.copy( vectorB );
		tmp.multiplyScalar( b );

		point.addSelf( tmp );

		tmp.copy( vectorC );
		tmp.multiplyScalar( c );

		point.addSelf( tmp );

		return point;

	}
1080422
@javax.annotation.Nonnull
  public static double[] sum(@javax.annotation.Nonnull final double[] a, final double b) {
    return com.simiacryptus.util.ArrayUtil.op(a, (x) -> x + b);
  }
1259617
def probability_density(self, X):
        
        self.check_fit()

        U, V = self.split_matrix(X)

        a = (self.theta + 1) * np.power(np.multiply(U, V), -(self.theta + 1))
        b = np.power(U, -self.theta) + np.power(V, -self.theta) - 1
        c = -(2 * self.theta + 1) / self.theta
        return a * np.power(b, c)
489501
public double getConditionalProbability(A first, B second) {
    return getCount(first, second) / conditionalCounts.get(first);
  }
353075
@Override
  public GallicWeight times(GallicWeight a, GallicWeight b) {
    if (isZero(a) || isZero(b)) {
      return zero;
    }
    IntArrayList newOutputLabels = new IntArrayList();
    newOutputLabels.addAll(a.getLabels());
    newOutputLabels.addAll(b.getLabels());
    double newWeight = this.weightSemiring.times(a.getWeight(), b.getWeight());
    return GallicWeight.create(newOutputLabels, newWeight);
  }
473566
def cumulative_distribution(self, X):
        
        self.check_fit()

        U, V = self.split_matrix(X)

        num = np.multiply(
            np.exp(np.multiply(-self.theta, U)) - 1,
            np.exp(np.multiply(-self.theta, V)) - 1
        )
        den = np.exp(-self.theta) - 1

        return -1.0 / self.theta * np.log(1 + num / den)
1316912
def constant_time_cmp(a, b):
    ''''''
    result = True
    for x, y in zip(a, b):
        result &= (x == y)
    return result
1059091
public double computeOverlap( ImageRectangle a , ImageRectangle b ) {
		if( !a.intersection(b,work) )
			return 0;

		int areaI = work.area();

		int bottom = a.area() + b.area() - areaI;

		return areaI/ (double)bottom;
	}
657810
public B getMostProbableOutcome(A first) {
    B best = null;
    double probability = -1.0;
    for (B second : getValues(first)) {
      if (getProbability(first, second) > probability) {
        probability = getProbability(first, second);
        best = second;
      }
    }
    return best;
  }
166764
public static double betaCdf(double x, double a, double b) {
        if(x<0 || a<=0 || b<=0) {
            throw new IllegalArgumentException("All the parameters must be positive.");
        }
        
        double Bcdf = 0.0;
        
        if(x==0) {
            return Bcdf;
        }
        else if (x>=1) {
            Bcdf=1.0;
            return Bcdf;
        }
        
        double S= a + b;

        double BT = Math.exp(logGamma(S)-logGamma(b)-logGamma(a)+a*Math.log(x)+b*Math.log(1-x));
        if (x<(a+1.0)/(S+2.0)) {
            Bcdf=BT*betinc(x,a,b);
        } 
        else {
            Bcdf=1.0-BT*betinc(1.0-x,b,a);
        }

        return Bcdf;
    }
27103
public double compare(String v1, String v2) {
    // FIXME: it should be possible here to say that, actually, we
    // didn't learn anything from comparing these two values, so that
    // probability is set to 0.5.

    if (comparator == null)
      return 0.5; // we ignore properties with no comparator

    // first, we call the comparator, to get a measure of how similar
    // these two values are. note that this is not the same as what we
    // are going to return, which is a probability.
    double sim = comparator.compare(v1, v2);

    // we have been configured with a high probability (for equal
    // values) and a low probability (for different values). given
    // sim, which is a measure of the similarity somewhere in between
    // equal and different, we now compute our estimate of the
    // probability.

    // if sim = 1.0, we return high. if sim = 0.0, we return low. for
    // values in between we need to compute a little.  the obvious
    // formula to use would be (sim * (high - low)) + low, which
    // spreads the values out equally spaced between high and low.

    // however, if the similarity is higher than 0.5 we don't want to
    // consider this negative evidence, and so there's a threshold
    // there.  also, users felt Duke was too eager to merge records,
    // and wanted probabilities to fall off faster with lower
    // probabilities, and so we square sim in order to achieve this.

    if (sim >= 0.5)
      return ((high - 0.5) * (sim * sim)) + 0.5;
    else
      return low;
  }
850764
public static double Incomplete(double a, double b, double x) {
        double aa, bb, t, xx, xc, w, y;
        boolean flag;

        if (a <= 0.0) {
            try {
                throw new IllegalArgumentException(" 'a' Lower limit must be greater than zero.");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (b <= 0.0) {
            try {
                throw new IllegalArgumentException(" 'b' Upper limit must be greater than zero.");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        if ((x <= 0.0) || (x >= 1.0)) {
            if (x == 0.0) return 0.0;
            if (x == 1.0) return 1.0;
            try {
                throw new IllegalArgumentException(" 'x' Value must be between 0 and 1.");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        flag = false;
        if ((b * x) <= 1.0 && x <= 0.95) {
            t = PowerSeries(a, b, x);
            return t;
        }

        w = 1.0 - x;

        if (x > (a / (a + b))) {
            flag = true;
            aa = b;
            bb = a;
            xc = x;
            xx = w;
        } else {
            aa = a;
            bb = b;
            xc = w;
            xx = x;
        }

        if (flag && (bb * xx) <= 1.0 && xx <= 0.95) {
            t = PowerSeries(aa, bb, xx);
            if (t <= Constants.DoubleEpsilon) t = 1.0 - Constants.DoubleEpsilon;
            else t = 1.0 - t;
            return t;
        }

        y = xx * (aa + bb - 2.0) - (aa - 1.0);
        if (y < 0.0)
            w = Incbcf(aa, bb, xx);
        else
            w = Incbd(aa, bb, xx) / xc;


        y = aa * Math.log(xx);
        t = bb * Math.log(xc);
        if ((aa + bb) < Gamma.GammaMax && Math.abs(y) < Constants.LogMax && Math.abs(t) < Constants.LogMax) {
            t = Math.pow(xc, bb);
            t *= Math.pow(xx, aa);
            t /= aa;
            t *= w;
            t *= Gamma.Function(aa + bb) / (Gamma.Function(aa) * Gamma.Function(bb));
            if (flag) {
                if (t <= Constants.DoubleEpsilon) t = 1.0 - Constants.DoubleEpsilon;
                else t = 1.0 - t;
            }
            return t;
        }

        y += t + Gamma.Log(aa + bb) - Gamma.Log(aa) - Gamma.Log(bb);
        y += Math.log(w / aa);
        if (y < Constants.LogMin)
            t = 0.0;
        else
            t = Math.exp(y);

        if (flag) {
            if (t <= Constants.DoubleEpsilon) t = 1.0 - Constants.DoubleEpsilon;
            else t = 1.0 - t;
        }
        return t;
    }
1015852
function regualizedBeta(x, a, b) {
	if(x < 0 || x > 1) {
    throw new RangeError('First argument must be between 0 and 1.');
	}

  // Special cases, there can make trouble otherwise
  else if (a === 1 && b === 1) return x;
  else if (x === 0) return 0;
  else if (x === 1) return 1;
  else if (a === 0) return 1;
  else if (b === 0) return 0;

  else {
    var bt =
      Math.exp(gammaCollection.logGamma(a + b) -
      gammaCollection.logGamma(a) -
      gammaCollection.logGamma(b) +
      a * Math.log(x) +
      b * log1p(-x));

    // Use continued fraction directly.
    if (x < (a + 1) / (a + b + 2)) return bt * betacf(x, a, b) / a;
    // else use continued fraction after making the symmetry transformation.
    else return 1 - bt * betacf(1 - x, b, a) / b;
  }
}