Example usage for org.apache.commons.math.util MathUtils binomialCoefficient

List of usage examples for org.apache.commons.math.util MathUtils binomialCoefficient

Introduction

In this page you can find the example usage for org.apache.commons.math.util MathUtils binomialCoefficient.

Prototype

public static long binomialCoefficient(final int n, final int k) 

Source Link

Document

Returns an exact representation of the <a href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial Coefficient</a>, "<code>n choose k</code>", the number of <code>k</code>-element subsets that can be selected from an <code>n</code>-element set.

Usage

From source file:no.sintef.ict.splcatool.TCalc.java

/**
 *  How many t-tuples does a row cover/*w  w w. ja  va 2  s  . com*/
 * @param n
 * @param t
 * @return
 */
public static long tsTotal(int n, int t) {
    return MathUtils.binomialCoefficient(2 * n, t);
}

From source file:no.sintef.ict.splcatool.TCalc.java

/**
 *  How many t-tuples does a row cover/*from w  ww  . j  a v  a  2 s .  c o m*/
 * @param n
 * @param t
 * @return
 */
public static long tsCovered(int n, int t) {
    if (n < t)
        return 0;
    return MathUtils.binomialCoefficient(n, t);
}

From source file:org.cimmyt.corehunter.search.KSubsetGenerator.java

public long getNrOfKSubsets() {
    return MathUtils.binomialCoefficient(n, k);
}

From source file:org.sosy_lab.ccvisu.measuring.ClusterQuality.java

/**
 * Calculate the density measure as described by Delling et al. 2007 in
 * "How to Evaluate Clustering Techniques"
 * @param graphData/*from w w w.  j  a va 2s  . c  o  m*/
 * @return Density
 */
public static double densityOfGraphClustering(GraphData graphData) {
    double intraClusterDensity = 0;
    double interClusterSparsity = 0;
    int graphInterClusterEdgeCount = 0;
    long graphBinCoeffSum = 0;

    Map<Group, ClusterMeasures> clusterMeasures = ClusterQuality.calulateClusterMeasures(graphData);
    for (Entry<Group, ClusterMeasures> entry : clusterMeasures.entrySet()) {
        Group group = entry.getKey();
        ClusterMeasures measures = entry.getValue();

        if (group.getKind() == GroupKind.CLUSTER) {
            long clusterBinCoeff = MathUtils.binomialCoefficient(group.getNodes().size(), 2);
            graphInterClusterEdgeCount += measures.countOfInterEdges;
            intraClusterDensity += measures.countOfIntraEdges / (double) clusterBinCoeff;
            graphBinCoeffSum += clusterBinCoeff;
        }
    }

    intraClusterDensity = intraClusterDensity / graphData.getVertices().size();
    interClusterSparsity = 1 - (graphInterClusterEdgeCount
            / ((double) (MathUtils.binomialCoefficient(graphData.getVertices().size(), 2) - graphBinCoeffSum)));

    return (intraClusterDensity / 2) + (interClusterSparsity / 2);
}