Gets the conditional probability of observing {@code second} given
{@code first}. Returns NaN if {@code first} has never been observed.

@param first
@param second
@return
489501
public double getConditionalProbability(A first, B second) {
    return getCount(first, second) / conditionalCounts.get(first);
  }
1303497
public static String subtractSeq(final String first, final String second) {
    return subtractSeq(first, second, DELIMITER);
  }
667666
public static <E> Set<E> intersection(Set<E> first, Set<E> second) {
        if (first == null || second == null) {
            return EMPTY_SET;
        }

        Set<E> intersection = new HashSet<>();

        for (E e : first) {
            if (second.contains(e)) {
                intersection.add(e);
            }
        }
        return intersection;
    }
511654
public static boolean isSecondNewerThanFirst(File first, File second) {
        boolean isSecondNewerThanFirst = false;
        // If file does not exist, it cannot be newer.
        if (second.exists()) {
            long firstLastModified = first.lastModified();
            long secondLastModified = second.lastModified();
            // 0L is returned if there was any error, so we check if both last
            // modification stamps are != 0L.
            if (firstLastModified != 0L && secondLastModified != 0L) {
                isSecondNewerThanFirst = secondLastModified > firstLastModified;
            }
        }
        return isSecondNewerThanFirst;
    }
654071
public double setCount(F first, S second, double value) {
        Counter<S> counter = maps.get(first);
        if (counter == null) {
            counter = new Counter<S>();
            maps.put(first, counter);
        }

        return counter.setCount(second, value);
    }
649259
@Beta
    public static <T> Predicate<T> nor(Predicate<? super T> first, Predicate<? super T> second) {
        return com.google.common.base.Predicates.not(com.google.common.base.Predicates.or(first, second));
    }
1001349
public static double[] doNaiveBayesPredictionLog(Instance inst,
            DoubleVector observedClassDistribution,
            AutoExpandVector<AttributeClassObserver> observers, AutoExpandVector<AttributeClassObserver> observers2) {
        AttributeClassObserver obs;
        double[] votes = new double[observedClassDistribution.numValues()];
        double observedClassSum = observedClassDistribution.sumOfValues();
        for (int classIndex = 0; classIndex < votes.length; classIndex++) {
            votes[classIndex] = Math.log10(observedClassDistribution.getValue(classIndex)
                    / observedClassSum);
            for (int attIndex = 0; attIndex < inst.numAttributes() - 1; attIndex++) {
                int instAttIndex = modelAttIndexToInstanceAttIndex(attIndex,
                        inst);
                if (inst.attribute(instAttIndex).isNominal()) {
                    obs = observers.get(attIndex);
                } else {
                    obs = observers2.get(attIndex);
                }

                if ((obs != null) && !inst.isMissing(instAttIndex)) {
                    votes[classIndex] += Math.log10(obs.probabilityOfAttributeValueGivenClass(inst.value(instAttIndex), classIndex));

                }
            }
        }
        return votes;

    }
60971
public int compareSwappedTo(IntIntPair other) {
    int fdiff = this.second - other.second;
    if(fdiff != 0) {
      return fdiff;
    }
    return this.first - other.first;
  }
673897
static public int compare(byte[] first, byte[] second) {
        // choose the shorter array length
        int firstLength = first.length;
        int secondLength = second.length;
        int shorterLength = Math.min(firstLength, secondLength);

        // compare matching bytes
        for (int i = 0; i < shorterLength; i++) {
            int result = Byte.compare(first[i], second[i]);
            if (result != 0) return Integer.signum(result);
        }

        // compare lengths if bytes match
        if (firstLength < secondLength) return -1;
        if (firstLength > secondLength) return 1;

        // must be same length and equal
        return 0;
    }
1189440
public V get(final K1 firstKey, final K2 secondKey) {
		// existence check on inner map
		final HashMap<K2, V> innerMap = map.get(firstKey);
		if( innerMap == null ) {
			return null;
		}
		return innerMap.get(secondKey);
	}
1143523
public boolean nextBoolean (final double probability)
        {
        if (probability < 0.0 || probability > 1.0)
            throw new IllegalArgumentException ("probability must be between 0.0 and 1.0 inclusive.");
        if (probability==0.0) return false;             // fix half-open issues
        else if (probability==1.0) return true; // fix half-open issues
        return nextDouble() < probability; 
        }
121186
public static <T> Predicate<T> or(final Predicate<? super T> first, final Predicate<? super T> second) {        //NOPMD
        return new Predicate<T>() {
            @Override
            public boolean test(final T testValue) {
                return first.test(testValue) || second.test(testValue);
            }
        };
    }
696998
@Beta
    public static <T> Predicate<T> nand(Predicate<? super T> first, Predicate<? super T> second) {
        return com.google.common.base.Predicates.not(com.google.common.base.Predicates.and(first, second));
    }
546685
public int countDifferencesBetweenIgnoreWhitespaceAnd(String first, String second) {
        String cleanFirst = allWhitespaceToSingleSpace(first);
        String cleanSecond = allWhitespaceToSingleSpace(second);
        return countDifferencesBetweenAnd(cleanFirst, cleanSecond);
    }
743503
public static <T> boolean isEqual(final T first, final T second) {
        /* test to see if they are both null, or both reference the same object */
        if (first == second) return true;

        if (first == null && second != null) return false;

        return first.equals(second);
    }
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;
  }
192749
public static <T> Collection<T> intersect(Collection<T> first,
                                              Collection<T> second) {
        E.checkNotNull(first, "first");
        E.checkNotNull(second, "second");

        HashSet<T> results = null;
        if (first instanceof HashSet) {
            @SuppressWarnings("unchecked")
            HashSet<T> clone = (HashSet<T>) ((HashSet<T>) first).clone();
            results = clone;
        } else {
            results = new HashSet<>(first);
        }
        results.retainAll(second);
        return results;
    }