本文整理汇总了Java中org.apache.commons.math3.distribution.PascalDistribution类的典型用法代码示例。如果您正苦于以下问题:Java PascalDistribution类的具体用法?Java PascalDistribution怎么用?Java PascalDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PascalDistribution类属于org.apache.commons.math3.distribution包,在下文中一共展示了PascalDistribution类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNextPascal
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
@Test
public void testNextPascal() {
PascalDistributionTest testInstance = new PascalDistributionTest();
int[] densityPoints = testInstance.makeDensityTestPoints();
double[] densityValues = testInstance.makeDensityTestValues();
int sampleSize = 1000;
int length = TestUtils.eliminateZeroMassPoints(densityPoints, densityValues);
PascalDistribution distribution = (PascalDistribution) testInstance.makeDistribution();
double[] expectedCounts = new double[length];
long[] observedCounts = new long[length];
for (int i = 0; i < length; i++) {
expectedCounts[i] = sampleSize * densityValues[i];
}
randomData.reSeed(1000);
for (int i = 0; i < sampleSize; i++) {
int value = randomData.nextPascal(distribution.getNumberOfSuccesses(), distribution.getProbabilityOfSuccess());
for (int j = 0; j < length; j++) {
if (value == densityPoints[j]) {
observedCounts[j]++;
}
}
}
TestUtils.assertChiSquareAccept(densityPoints, expectedCounts, observedCounts, .001);
}
示例2: CMParameters
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
/**
* Constructs a new <code>CMParameters</code> configured from the given <code>MergeContext</code>.
*
* @param context
* the <code>MergeContext</code> to use
*/
public CMParameters(MergeContext context) {
setNoMatchWeight(context.getWn());
setRenamingWeight(context.getWr());
setAncestryViolationWeight(context.getWa());
setSiblingGroupBreakupWeight(context.getWs());
setOrderingWeight(context.getWo());
rng = new RandomAdaptor(context.getSeed().map(Well19937c::new).orElse(new Well19937c()));
assignDist = new PascalDistribution(rng, 1, context.getpAssign());
setPAssign(context.getpAssign());
setFixLower(context.getFixLower());
setFixUpper(context.getFixUpper());
setBeta(30);
setParallel(context.isCmMatcherParallel());
setFixRandomPercentage(context.isCmMatcherFixRandomPercentage());
lcaCache = new ConcurrentHashMap<>();
siblingCache = new ConcurrentHashMap<>();
otherSiblingsCache = new ConcurrentHashMap<>();
exactContainsCache = new ConcurrentHashMap<>();
boundContainsCache = new ConcurrentHashMap<>();
}
示例3: getPascal
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
@Override
public RandomNumberDistribution<Integer> getPascal(
final RandomNumberStream rng, final Number r, final Number p)
{
final IntegerDistribution dist = new PascalDistribution(
RandomNumberStream.Util.asCommonsRandomGenerator(rng),
r.intValue(), p.doubleValue());
return new RandomNumberDistribution<Integer>()
{
@Override
public Integer draw()
{
return dist.sample();
}
};
}
示例4: SamplingIterator
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
public SamplingIterator(RandomWrapper random, Iterator<? extends T> delegate, double samplingRate) {
Preconditions.checkNotNull(delegate);
Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0);
// Geometric distribution is special case of negative binomial (aka Pascal) with r=1:
geometricDistribution = new PascalDistribution(random.getRandomGenerator(), 1, samplingRate);
this.delegate = delegate;
}
示例5: SamplingLongPrimitiveIterator
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
public SamplingLongPrimitiveIterator(final RandomWrapper random,
final LongPrimitiveIterator delegate, final double samplingRate) {
Preconditions.checkNotNull(delegate);
Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0,
"Must be: 0.0 < samplingRate <= 1.0");
// Geometric distribution is special case of negative binomial (aka Pascal) with r=1:
geometricDistribution = new PascalDistribution(
random.getRandomGenerator(), 1, samplingRate);
this.delegate = delegate;
hasNext = true;
doNext();
}
示例6: SamplingLongPrimitiveIterator
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
/**
*
* @param random random number generator to re-use
* @param delegate iterator to sample from
* @param samplingRate sampling rate in (0,1]
*/
public SamplingLongPrimitiveIterator(RandomGenerator random, LongPrimitiveIterator delegate, double samplingRate) {
Preconditions.checkNotNull(random);
Preconditions.checkNotNull(delegate);
Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0);
// Geometric distribution is special case of negative binomial (aka Pascal) with r=1:
geometricDistribution = new PascalDistribution(random, 1, samplingRate);
this.delegate = delegate;
this.hasNext = true;
doNext();
}
示例7: SamplingLongPrimitiveIterator
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
public SamplingLongPrimitiveIterator(RandomGenerator random, LongPrimitiveIterator delegate, double samplingRate) {
Preconditions.checkNotNull(random);
Preconditions.checkNotNull(delegate);
Preconditions.checkArgument(samplingRate > 0.0 && samplingRate <= 1.0);
// Geometric distribution is special case of negative binomial (aka Pascal) with r=1:
geometricDistribution = new PascalDistribution(random, 1, samplingRate);
this.delegate = delegate;
this.hasNext = true;
doNext();
}
示例8: nextPascal
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
/**
* Generates a random value from the {@link PascalDistribution Pascal Distribution}.
*
* @param r the number of successes of the Pascal distribution
* @param p the probability of success of the Pascal distribution
* @return random value sampled from the Pascal(r, p) distribution
* @throws NotStrictlyPositiveException if the number of successes is not positive
* @throws OutOfRangeException if the probability of success is not in the
* range {@code [0, 1]}.
*/
public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException {
return new PascalDistribution(getRandomGenerator(), r, p).sample();
}
示例9: nextPascal
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
/**
* Generates a random value from the {@link PascalDistribution Pascal Distribution}.
* This implementation uses {@link #nextInversionDeviate(IntegerDistribution) inversion}
* to generate random values.
*
* @param r the number of successes of the Pascal distribution
* @param p the probability of success of the Pascal distribution
* @return random value sampled from the Pascal(r, p) distribution
* @since 2.2
*/
public int nextPascal(int r, double p) {
return nextInversionDeviate(new PascalDistribution(r, p));
}
示例10: nextPascal
import org.apache.commons.math3.distribution.PascalDistribution; //导入依赖的package包/类
/**
* Generates a random value from the {@link PascalDistribution Pascal Distribution}.
*
* @param r the number of successes of the Pascal distribution
* @param p the probability of success of the Pascal distribution
* @return random value sampled from the Pascal(r, p) distribution
* @throws NotStrictlyPositiveException if the number of successes is not positive
* @throws OutOfRangeException if the probability of success is not in the
* range {@code [0, 1]}.
*/
public int nextPascal(int r, double p) throws NotStrictlyPositiveException, OutOfRangeException {
return new PascalDistribution(getRan(), r, p).sample();
}