当前位置: 首页>>代码示例>>Java>>正文


Java CombinatoricsUtils.binomialCoefficient方法代码示例

本文整理汇总了Java中org.apache.commons.math3.util.CombinatoricsUtils.binomialCoefficient方法的典型用法代码示例。如果您正苦于以下问题:Java CombinatoricsUtils.binomialCoefficient方法的具体用法?Java CombinatoricsUtils.binomialCoefficient怎么用?Java CombinatoricsUtils.binomialCoefficient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.util.CombinatoricsUtils的用法示例。


在下文中一共展示了CombinatoricsUtils.binomialCoefficient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCandidateIndices

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * @param vector vector whose dot product with hashed vectors is to be maximized
 * @return indices of partitions containing candidates to check
 */
int[] getCandidateIndices(float[] vector) {
  int mainIndex = getIndexFor(vector);
  // Simple cases
  int numHashes = getNumHashes();
  if (numHashes == maxBitsDiffering) {
    return allIndices;
  }
  if (maxBitsDiffering == 0) {
    return new int[] { mainIndex };
  }
  // Other cases
  int howMany = 0;
  for (int i = 0; i <= maxBitsDiffering; i++) {
    howMany += (int) CombinatoricsUtils.binomialCoefficient(numHashes, i);
  }
  int[] result = new int[howMany];
  System.arraycopy(candidateIndicesPrototype, 0, result, 0, howMany);
  for (int i = 0; i < howMany; i++) {
    result[i] ^= mainIndex;
  }
  return result;
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:27,代码来源:LocalitySensitiveHash.java

示例2: doTestHashesBits

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
private static void doTestHashesBits(double sampleRate, int numCores, int numHashes, int maxBitsDiffering) {
  LocalitySensitiveHash lsh = new LocalitySensitiveHash(sampleRate, 10, numCores);
  assertEquals(numHashes, lsh.getNumHashes());
  assertEquals(1L << numHashes, lsh.getNumPartitions());
  assertEquals(maxBitsDiffering, lsh.getMaxBitsDiffering());
  if (sampleRate == 1.0) {
    assertEquals(lsh.getMaxBitsDiffering(), lsh.getNumHashes());
  }
  long partitionsToTry = 0;
  for (int i = 0; i <= maxBitsDiffering; i++) {
    partitionsToTry += CombinatoricsUtils.binomialCoefficient(numHashes, i);
  }
  if (numHashes < LocalitySensitiveHash.MAX_HASHES) {
    assertLessOrEqual((double) partitionsToTry / (1 << numHashes), sampleRate);
  }
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:17,代码来源:LocalitySensitiveHashTest.java

示例3: BinomialModelFunctionGradient

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
public BinomialModelFunctionGradient(double[] histogram, int trials, boolean zeroTruncated)
{
	super(histogram, trials, zeroTruncated);

	// We could ignore the first p value as it is always zero:
	//p = Arrays.copyOfRange(p, 1, p.length);
	// BUT then we would have to override the getP() method since this has 
	// an offset of 1 and assumes the index of p is X.

	final int n = trials;
	nC = new long[n + 1];
	for (int k = 0; k <= n; k++)
	{
		nC[k] = CombinatoricsUtils.binomialCoefficient(n, k);
	}
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:17,代码来源:BinomialFitter.java

示例4: createRadialPolynomial

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
/**
 * Creates and returns a new radial polynomial (R_nm) given two moments.
 *
 * @param n 1st moment (order) of the radial polynomial.
 * @param m 2nd moment (repetition) of the radial polynomial.
 * @return PolynomialFunction representing R_nm
 * @throws ArithmeticException If orders are to large and calculation of binomial coefficients fail.
 */
public static PolynomialFunction createRadialPolynomial(final int n, int m) {
    m = Math.abs(m); /* Make sure that m is positive. */
    String id = n + "-" + m; /* Construct ID for cache lookup. */

    /* Try to retrieve the function from cache. */
    if (RADIAL_FUNCTION_CACHE.containsKey(id)) {
        return RADIAL_FUNCTION_CACHE.get(id);
    }

    /* Initialize coefficients. */
    double[] coefficients = new double[n + 1];

    /* Now check if Polynomial 0 (for n-|m| = odd) .*/
    if ((n - m) % 2 != 0) {
      return new PolynomialFunction(coefficients); /* If (n-m) != even, return 0 function. */
    }
    int s_max = (n - m) / 2;

    double sign = -1.0;
    for (int s = 0; s <= s_max; ++s) {
        int position = n - 2 * s;
        long a = CombinatoricsUtils.binomialCoefficient(n-s, s);
        long b = CombinatoricsUtils.binomialCoefficient(n-2*s, s_max - s);
        coefficients[position] = (FastMath.pow(sign,s) * a * b);
    }

    PolynomialFunction function = new PolynomialFunction(coefficients);
    RADIAL_FUNCTION_CACHE.put(id, function);
    return function;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:39,代码来源:PolynomialFunctionFactory.java

示例5: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph() throws Exception {
	// all vertex pairs are linked
	long expectedCount = CombinatoricsUtils.binomialCoefficient((int) completeGraphVertexCount, 2);

	// the intersection includes every vertex
	long expectedDistinctNeighborCount = completeGraphVertexCount;

	// the union only excludes the two vertices from the similarity score
	long expectedSharedNeighborCount = completeGraphVertexCount - 2;

	validate(completeGraph, expectedCount, expectedDistinctNeighborCount, expectedSharedNeighborCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:JaccardIndexTest.java

示例6: testWithStarGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithStarGraph() throws Exception {
	// all leaf vertices form a triplet with all other leaf vertices;
	// only the center vertex is excluded
	long expectedCount = CombinatoricsUtils.binomialCoefficient((int) starGraphVertexCount - 1, 2);

	// the intersection includes only the center vertex
	long expectedDistinctNeighborCount = 1;

	// the union includes only the center vertex
	long expectedSharedNeighborCount = 1;

	validate(starGraph, expectedCount, expectedDistinctNeighborCount, expectedSharedNeighborCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:JaccardIndexTest.java

示例7: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph() throws Exception {
	// all vertex pairs are linked
	long expectedCount = CombinatoricsUtils.binomialCoefficient((int) completeGraphVertexCount, 2);

	float expectedScore = (completeGraphVertexCount - 2) / (float) Math.log(completeGraphVertexCount - 1);

	validate(completeGraph, expectedCount, expectedScore);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:10,代码来源:AdamicAdarTest.java

示例8: testWithStarGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithStarGraph() throws Exception {
	// all leaf vertices form a triplet with all other leaf vertices;
	// only the center vertex is excluded
	long expectedCount = CombinatoricsUtils.binomialCoefficient((int) starGraphVertexCount - 1, 2);

	// the intersection includes only the center vertex
	float expectedScore = 1 / (float) Math.log(starGraphVertexCount - 1);

	validate(starGraph, expectedCount, expectedScore);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:12,代码来源:AdamicAdarTest.java

示例9: testCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testCompleteGraph() throws Exception {
	long degree = completeGraphVertexCount - 1;
	long triangleCount = 2 * CombinatoricsUtils.binomialCoefficient((int) degree, 2);

	validate(completeGraph, completeGraphVertexCount, degree, triangleCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:LocalClusteringCoefficientTest.java

示例10: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph() throws Exception {
	long expectedDegree = completeGraphVertexCount - 1;
	long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2);

	validate(completeGraph, expectedCount, expectedCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:GlobalClusteringCoefficientTest.java

示例11: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph()
		throws Exception {
	long expectedDegree = completeGraphVertexCount - 1;
	long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int)expectedDegree, 2) / 3;

	long triangleCount = new TriangleCount<LongValue, NullValue, NullValue>()
		.run(completeGraph)
		.execute();

	assertEquals(expectedCount, triangleCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:TriangleCountTest.java

示例12: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph() throws Exception {
	long expectedDegree = completeGraphVertexCount - 1;
	long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3;

	Result expectedResult = new Result(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedCount);

	Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>()
		.run(completeGraph)
		.execute();

	assertEquals(expectedResult, triadCensus);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:TriadicCensusTest.java

示例13: testCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testCompleteGraph() throws Exception {
	long degree = completeGraphVertexCount - 1;
	long triangleCount = CombinatoricsUtils.binomialCoefficient((int) degree, 2);

	validate(completeGraph, completeGraphVertexCount, degree, triangleCount);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:LocalClusteringCoefficientTest.java

示例14: testWithCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testWithCompleteGraph() throws Exception {
	long expectedDegree = completeGraphVertexCount - 1;
	long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3;

	Result expectedResult = new Result(0, 0, 0, expectedCount);

	Result triadCensus = new TriadicCensus<LongValue, NullValue, NullValue>()
		.run(completeGraph)
		.execute();

	assertEquals(expectedResult, triadCensus);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:14,代码来源:TriadicCensusTest.java

示例15: testCompleteGraph

import org.apache.commons.math3.util.CombinatoricsUtils; //导入方法依赖的package包/类
@Test
public void testCompleteGraph() throws Exception {
	long expectedDegree = completeGraphVertexCount - 1;
	long expectedCount = completeGraphVertexCount * CombinatoricsUtils.binomialCoefficient((int) expectedDegree, 2) / 3;

	DataSet<Result<LongValue>> tl = completeGraph
		.run(new TriangleListing<>());

	Checksum checksum = new ChecksumHashCode<Result<LongValue>>()
		.run(tl)
		.execute();

	assertEquals(expectedCount, checksum.getCount());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:15,代码来源:TriangleListingTest.java


注:本文中的org.apache.commons.math3.util.CombinatoricsUtils.binomialCoefficient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。