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


Java LocalizedFormats.NUMBER_OF_SAMPLES属性代码示例

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


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

示例1: sample

/**
 * Generate a random sample from the distribution.
 *
 * @param sampleSize the number of random values to generate.
 * @return an array representing the random sample.
 * @throws NotStrictlyPositiveException if {@code sampleSize} is not
 * positive.
 */
public Object[] sample(int sampleSize) throws NotStrictlyPositiveException {
    if (sampleSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                sampleSize);
    }

    final Object[] out = new Object[sampleSize];

    for (int i = 0; i < sampleSize; i++) {
        out[i] = sample();
    }

    return out;

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:23,代码来源:EnumeratedDistribution.java

示例2: nextSample

/**
 * {@inheritDoc}
 *
 * This method calls {@link #nextPermutation(int,int) nextPermutation(c.size(), k)}
 * in order to sample the collection.
 */
public Object[] nextSample(Collection<?> c, int k) throws NumberIsTooLargeException, NotStrictlyPositiveException {

    int len = c.size();
    if (k > len) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_EXCEEDS_COLLECTION_SIZE,
                                            k, len, true);
    }
    if (k <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES, k);
    }

    Object[] objects = c.toArray();
    int[] index = nextPermutation(len, k);
    Object[] result = new Object[k];
    for (int i = 0; i < k; i++) {
        result[i] = objects[index[i]];
    }
    return result;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:25,代码来源:RandomDataGenerator.java

示例3: sample

/**
 * {@inheritDoc}
 *
 * The default implementation generates the sample by calling
 * {@link #sample()} in a loop.
 */
public double[] sample(int sampleSize) {
    if (sampleSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                sampleSize);
    }
    double[] out = new double[sampleSize];
    for (int i = 0; i < sampleSize; i++) {
        out[i] = sample();
    }
    return out;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:17,代码来源:AbstractRealDistribution.java

示例4: sample

/**
 * {@inheritDoc}
 *
 * The default implementation generates the sample by calling
 * {@link #sample()} in a loop.
 */
public int[] sample(int sampleSize) {
    if (sampleSize <= 0) {
        throw new NotStrictlyPositiveException(
                LocalizedFormats.NUMBER_OF_SAMPLES, sampleSize);
    }
    int[] out = new int[sampleSize];
    for (int i = 0; i < sampleSize; i++) {
        out[i] = sample();
    }
    return out;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:17,代码来源:AbstractIntegerDistribution.java

示例5: sample

/** {@inheritDoc} */
public double[][] sample(final int sampleSize) {
    if (sampleSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                               sampleSize);
    }
    final double[][] out = new double[sampleSize][dimension];
    for (int i = 0; i < sampleSize; i++) {
        out[i] = sample();
    }
    return out;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:12,代码来源:AbstractMultivariateRealDistribution.java

示例6: HypergeometricDistribution

/**
 * Creates a new hypergeometric distribution.
 *
 * @param rng Random number generator.
 * @param populationSize Population size.
 * @param numberOfSuccesses Number of successes in the population.
 * @param sampleSize Sample size.
 * @throws NotPositiveException if {@code numberOfSuccesses < 0}.
 * @throws NotStrictlyPositiveException if {@code populationSize <= 0}.
 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > populationSize},
 * or {@code sampleSize > populationSize}.
 * @since 3.1
 */
public HypergeometricDistribution(RandomGenerator rng,
                                  int populationSize,
                                  int numberOfSuccesses,
                                  int sampleSize)
throws NotPositiveException, NotStrictlyPositiveException, NumberIsTooLargeException {
    super(rng);

    if (populationSize <= 0) {
        throw new NotStrictlyPositiveException(LocalizedFormats.POPULATION_SIZE,
                                               populationSize);
    }
    if (numberOfSuccesses < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SUCCESSES,
                                       numberOfSuccesses);
    }
    if (sampleSize < 0) {
        throw new NotPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,
                                       sampleSize);
    }

    if (numberOfSuccesses > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.NUMBER_OF_SUCCESS_LARGER_THAN_POPULATION_SIZE,
                                            numberOfSuccesses, populationSize, true);
    }
    if (sampleSize > populationSize) {
        throw new NumberIsTooLargeException(LocalizedFormats.SAMPLE_SIZE_LARGER_THAN_POPULATION_SIZE,
                                            sampleSize, populationSize, true);
    }

    this.numberOfSuccesses = numberOfSuccesses;
    this.populationSize = populationSize;
    this.sampleSize = sampleSize;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:46,代码来源:HypergeometricDistribution.java


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