org.apache.commons.math3.distribution.CauchyDistribution Java Examples

The following examples show how to use org.apache.commons.math3.distribution.CauchyDistribution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RandomDataGeneratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #2
Source File: RandomDataGeneratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #3
Source File: RandomDataGeneratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #4
Source File: RandomDataGeneratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #5
Source File: RandomDataTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() throws Exception {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #6
Source File: RandomDataTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #7
Source File: RandomDataTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #8
Source File: RandomDataGeneratorTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testNextCauchy() {
    double[] quartiles = TestUtils.getDistributionQuartiles(new CauchyDistribution(1.2, 2.1));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextCauchy(1.2, 2.1);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
Example #9
Source File: CopyRatioHMM.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Visible for the segmenter
 */
public static double logEmissionProbability(final Double data, final double log2CopyRatio, final double cauchyWidth) {
    return new CauchyDistribution(null, log2CopyRatio, cauchyWidth).logDensity(data);
}
 
Example #10
Source File: CopyRatioHMM.java    From gatk-protected with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * @param log2CopyRatios array of log-2 copy ratios corresponding to the hidden states
 * @param weights array of (real-space, not log) prior probabilities of each hidden state
 *                when memory of the previous state is lost.  These may be unnormalized relative
 *                probabilities, which is useful when using variational Bayes.
 * @param memoryLength when consecutive SNPs are a distance d bases apart, the prior probability
 *                     for memory of the CNV state to be kept is exp(-d/memoryLength)
 */
public CopyRatioHMM(final List<Double> log2CopyRatios, final List<Double> weights,
                    final double memoryLength, final double logCoverageCauchyWidth) {
    super(log2CopyRatios, weights, memoryLength);
    this.logCoverageCauchyWidth = logCoverageCauchyWidth;
    emissionDistributions = hiddenStates().stream()
            .map(n -> new CauchyDistribution(null, log2CopyRatios.get(n), logCoverageCauchyWidth)).collect(Collectors.toList());
}
 
Example #11
Source File: RandomDataImpl.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 * This implementation uses {@link #nextInversionDeviate(RealDistribution) inversion}
 * to generate random values.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 * @since 2.2
 */
public double nextCauchy(double median, double scale) {
    return nextInversionDeviate(new CauchyDistribution(median, scale));
}
 
Example #12
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRandomGenerator(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
Example #13
Source File: RandomDataImpl.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 * This implementation uses {@link #nextInversionDeviate(RealDistribution) inversion}
 * to generate random values.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 * @since 2.2
 */
public double nextCauchy(double median, double scale) {
    return nextInversionDeviate(new CauchyDistribution(median, scale));
}
 
Example #14
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRan(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
Example #15
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRandomGenerator(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
Example #16
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRandomGenerator(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
Example #17
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRandomGenerator(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}
 
Example #18
Source File: RandomDataGenerator.java    From astor with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Generates a random value from the {@link CauchyDistribution Cauchy Distribution}.
 *
 * @param median the median of the Cauchy distribution
 * @param scale the scale parameter of the Cauchy distribution
 * @return random value sampled from the Cauchy(median, scale) distribution
 */
public double nextCauchy(double median, double scale) {
    return new CauchyDistribution(getRandomGenerator(), median, scale,
            CauchyDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
}