Calculates the exact odds.
19198
function (hands, table, dead) {
		// Preprocesses the input data.
		table = table ? _.map(table, getCode) : [];
		dead = dead ? _.map(dead, getCode) : [];
		hands = _.map(hands, function (hand) {
			return _.map(hand, getCode);
		});
		var res = deckSize + 1;
		for (var c = 0; c < table.length; c++)
			res = evaluator[res + table[c]];
		var deck = _.chain(_.range(1, deckSize + 1)).difference(table)
				.difference(_.flatten(hands)).difference(dead).value();
		var player = _.map(hands, function (hand) {
			return evaluator[evaluator[res + hand[0]] + hand[1]];
		});
		var combinations = function (n, k, res, callback) {
			if (k <= 0) {
				callback(res);
			} else {
				while (n < deck.length) {
					var parcial = evaluator[res + deck[n++]];
					combinations(n, k - 1, parcial, callback);
				}
			}
		};
		
		// Calculates the outcome of each play.
		var remaining = 5 - table.length;
		var plays = deck.length / remaining;
		for (var c = 1; c < remaining; c++)
			plays *= (deck.length - c) / c;
		var values = new Array(hands.length);
		for (var p = 0; p < hands.length; p++) {
			var s = 0;
			values[p] = new Int32Array(plays);
			combinations(0, remaining, player[p], function (res) {
				values[p][s++] = res;
			});
		}
		
		// Determines the results.
		var wins = new Int32Array(hands.length);
		var splits = new Int32Array(hands.length);
		for (var s = 0; s < plays; s++) {
			var winner = [0];
			for (var p = 1; p < hands.length; p++) {
				if (values[p][s] > values[winner[0]][s])
					winner = [p];
				else if (values[p][s] == values[winner[0]][s])
					winner.push(p);
			}
			if (winner.length == 1) {
				wins[winner[0]]++;
			} else {
				for (var p = 0; p < winner.length; p++)
					splits[winner[p]]++;
			}
		}
		
		// Formats odds output.
		var odds = [];
		for (var p = 0; p < hands.length; p++)
			odds[p] = {win: wins[p] / plays, split: splits[p] / plays};
		return odds;
	}
108041
def _calculate_options(self):
        """"""
        _options = self._default_options.copy()
        _options.update(self.options)
        if self.options_param:
            _options.update(self.options_param)
        return _options
1178151
def _calculate(numbers, symbols):
        """"""
        if len(numbers) is 1:
            return numbers[0]

        precedence = [[pow], [mul, div], [add, sub]]

        # Find most important operation
        for op_group in precedence:
            for i, op in enumerate(symbols):
                if op in op_group:
                    # Apply operation
                    a = numbers[i]
                    b = numbers[i + 1]
                    result = MathService._applyBinary(a, b, op)
                    new_numbers = numbers[:i] + [result] + numbers[i + 2:]
                    new_symbols = symbols[:i] + symbols[i + 1:]

                    return MathService._calculate(new_numbers, new_symbols)
1343768
private static int chooseWithProbability(double[] distances,
                                             double sum,
                                             double probability) {
        for (int j = 0; j < distances.length; ++j) {
            double probOfDistance = Math.pow(distances[j], 2) / sum;
            probability -= probOfDistance;
            if (probability <= EPSILON) {
                return j;
            }
        }
        return distances.length-1;
    }
757976
def choose(self):
        """"""
        if not self.choosed:
            self.choosed = True
            self.pos = self.pos + Sep(5, 0)
965060
public static boolean chance(float chances, float maxChances) {
		chances = chances >= 0 ? chances : 0;
		maxChances = maxChances >= 0 ? maxChances : 0;
		if (chances == 0 && maxChances == 0)
			return false;

		maxChances = Math.max(maxChances, chances);
		double start = (maxChances - chances) / 2;
		double end = start + chances;
		double hit = _random.nextDouble() * maxChances;
		return hit >= start && hit <= end;
	}
1274294
def score_small_straight_yahztee(dice: List[int]) -> int:
    
    global CONSTANT_SCORES_YAHTZEE
    dice_set = set(dice)
    if _are_two_sets_equal({1, 2, 3, 4}, dice_set) or \
            _are_two_sets_equal({2, 3, 4, 5}, dice_set) or \
            _are_two_sets_equal({3, 4, 5, 6}, dice_set):
        return CONSTANT_SCORES_YAHTZEE[Category.SMALL_STRAIGHT]
    return 0
146419
public function calculate()
    {
        $this->calculatePageLimitAndOffset();
        $pageNumber = $this->getPageNumber();
        $offset = $this->getPaginationOffset();


        /* Setup page vars for display. */
        if ($pageNumber == 0) {
            $pageNumber = 1; //if no page var is given, default to 1.
        }
        $this->previous = $pageNumber - 1;
        $this->next = $pageNumber + 1;
        //last page is = total pages / items per page, rounded up.
        $this->lastPage = ceil($this->getTotalNumberOfPages() / $this->perPage);

        $this->lastPageMinusOne = $this->lastPage - 1;  //last page minus 1
        $this->create();
    }
904440
def compute_amount(self):
        """"""
        self.amount = self.base_amount * self.aliquot / 100
        return self.amount
539185
public double computeLikelihoodP() {
        double ret = 1.0;

        for( int i = 0; i < r.numRows; i++ ) {
            double a = r.get(i,0);

            ret *= Math.exp(-a*a/2.0);
        }

        return ret;
    }
376627
def exact(cls, value, precision=None):
        
        # figure out precision to use
        if isinstance(value, six.string_types):
            if precision is None:
                raise TypeError("precision must be supplied when "
                                "converting from a string")
        else:
            if precision is not None:
                raise TypeError("precision argument should not be "
                                "specified except when converting "
                                "from a string")
            if isinstance(value, float):
                precision = _builtin_max(DBL_PRECISION, PRECISION_MIN)
            elif isinstance(value, six.integer_types):
                precision = _builtin_max(_bit_length(value), PRECISION_MIN)
            elif isinstance(value, BigFloat):
                precision = value.precision
            else:
                raise TypeError("Can't convert argument %s of type %s "
                                "to BigFloat" % (value, type(value)))

        # Use unlimited exponents, with given precision.
        with _saved_flags():
            set_flagstate(set())  # clear all flags
            context = (
                WideExponentContext +
                Context(precision=precision) +
                RoundTiesToEven
            )
            with context:
                result = BigFloat(value)
            if test_flag(Overflow):
                raise ValueError("value too large to represent as a BigFloat")
            if test_flag(Underflow):
                raise ValueError("value too small to represent as a BigFloat")
            if test_flag(Inexact) and not isinstance(value, six.string_types):
                # since this is supposed to be an exact conversion, the
                # inexact flag should never be set except when converting
                # from a string.
                assert False, ("Inexact conversion in BigFloat.exact. "
                               "This shouldn't ever happen.  Please report.")

        return result
1095219
public function guess() : float
    {
        if ($this->percentile === null or $this->mad === null) {
            throw new RuntimeException('Strategy has not been fitted.');
        }

        return $this->percentile
            + $this->blur
            * $this->gaussian()
            * $this->mad;
    }
1070087
def _calc_F_guess(self, alpha, predictions, theta, weights):
        """"""
        num = np.sum(predictions.T * theta * weights, axis=1)
        den = np.sum((1 - alpha) * theta * weights + \
                     alpha * predictions.T * weights, axis=1)
        F_guess = num/den
        # Ensure guess is not undefined
        F_guess[den==0] = 0.5
        return F_guess
509618
private int precisionSum(List<UnitFactor> factors) {
    return factors.stream().map(f -> totalPrecision(f.rational())).reduce(0, Math::addExact);
  }
1160390
protected int CalcBias(int Offset,int Font)
	{
		seek(Offset);
		int nSubrs = getCard16();
		// If type==1 -> bias=0 
		if (fonts[Font].CharstringType == 1)
			return 0;
		// else calc according to the count
		else if (nSubrs < 1240)
			return 107;
		else if (nSubrs < 33900)
			return 1131;
		else
			return 32768;
	}
577953
def call
      probability = 1.0

      graders.each do |lambda|
        instance = lambda.call(description)
        probability *= instance.call.to_f ** instance.weight
      end

      probability
    end
917500
def _bracket_exact_var(self, symbol):
        """"""
        if isinstance(self.element, Executable):
            if symbol in self.element.parameters:
                return self.element.parameters[symbol]            
            if symbol in self.element.members:
                return self.element.members[symbol]

        if symbol in self.element.module.members:
            return self.element.module.members[symbol]

        return None