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


Java BetaDistributionImpl类代码示例

本文整理汇总了Java中org.apache.commons.math.distribution.BetaDistributionImpl的典型用法代码示例。如果您正苦于以下问题:Java BetaDistributionImpl类的具体用法?Java BetaDistributionImpl怎么用?Java BetaDistributionImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testNextInversionDeviate

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void testNextInversionDeviate() throws Exception {
    // Set the seed for the default random generator
    randomData.reSeed(100);
    double[] quantiles = new double[10];
    for (int i = 0; i < 10; i++) {
        quantiles[i] = randomData.nextUniform(0, 1);
    }
    // Reseed again so the inversion generator gets the same sequence
    randomData.reSeed(100);
    BetaDistributionImpl betaDistribution = new BetaDistributionImpl(2, 4);
    /*
     *  Generate a sequence of deviates using inversion - the distribution function
     *  evaluated at the random value from the distribution should match the uniform
     *  random value used to generate it, which is stored in the quantiles[] array.
     */
    for (int i = 0; i < 10; i++) {
        double value = randomData.nextInversionDeviate(betaDistribution);
        assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
    } 
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:RandomDataTest.java

示例2: testNextInversionDeviate

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
@Test
public void testNextInversionDeviate() throws Exception {
    // Set the seed for the default random generator
    randomData.reSeed(100);
    double[] quantiles = new double[10];
    for (int i = 0; i < 10; i++) {
        quantiles[i] = randomData.nextUniform(0, 1);
    }
    // Reseed again so the inversion generator gets the same sequence
    randomData.reSeed(100);
    BetaDistributionImpl betaDistribution = new BetaDistributionImpl(2, 4);
    /*
     *  Generate a sequence of deviates using inversion - the distribution function
     *  evaluated at the random value from the distribution should match the uniform
     *  random value used to generate it, which is stored in the quantiles[] array.
     */
    for (int i = 0; i < 10; i++) {
        double value = randomData.nextInversionDeviate(betaDistribution);
        Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
    }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:22,代码来源:RandomDataTest.java

示例3: nextBeta

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
static public double nextBeta(double alpha, double beta) {
	BetaDistribution distr = new BetaDistributionImpl(alpha, beta);
	double v = 0;
	try {
		v = distr.inverseCumulativeProbability(Randomizer.nextDouble());
	} catch (MathException e) {
		e.printStackTrace();
	}
	return v;		
}
 
开发者ID:BEAST2-Dev,项目名称:nested-sampling,代码行数:11,代码来源:NSLogAnalyser.java

示例4: getDomainValue

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
@Override
public double getDomainValue(AnthHost domain) {
	BetaDistributionImpl bd = new BetaDistributionImpl(domain.goodUrls
			+ alpha, domain.badUrls + beta);
	try {
		return bd.sample();
	} catch (MathException e) {
		System.out
				.println("Could not get random value from BetaDistribution for "
						+ domain.host);
		return 0.0;
	}
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:14,代码来源:ThompsonSampling.java

示例5: main

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public static void main(String[] args) throws MathException {
	BetaDistributionImpl bd = new BetaDistributionImpl(10, 100);
	BetaDistributionImpl bd1 = new BetaDistributionImpl(1, 10);
	for (int i = 0; i < 10; i++) {
		System.out.println("" + bd.sample() + " " + bd.getNumericalMean()
				+ " " + bd1.sample() + " " + bd1.getNumericalMean());
	}

}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:10,代码来源:ThompsonSampling.java

示例6: testNextBeta

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void testNextBeta() throws Exception {
    double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistributionImpl(2,5));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextBeta(2, 5);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:RandomDataTest.java

示例7: testNextBeta

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
@Test
public void testNextBeta() throws Exception {
    double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistributionImpl(2,5));
    long[] counts = new long[4];
    randomData.reSeed(1000);
    for (int i = 0; i < 1000; i++) {
        double value = randomData.nextBeta(2, 5);
        TestUtils.updateCounts(value, counts, quartiles);
    }
    TestUtils.assertChiSquareAccept(expected, counts, 0.001);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:RandomDataTest.java

示例8: CusumElement

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public CusumElement(double alphaPreChange, double betaPreChange, double alphaPostChange, double betaPostChange, double preChangeMean, double cusumScore){
    this.preChangeDist = new BetaDistributionImpl(alphaPreChange, betaPreChange);
    this.postChangeDist = new BetaDistributionImpl(alphaPostChange, betaPostChange);
    this.preChangeMean = preChangeMean;
    this.cusumScore = cusumScore;
}
 
开发者ID:ahaque-utd,项目名称:ECHO,代码行数:7,代码来源:CusumElement.java

示例9: getPreChangeDist

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public BetaDistributionImpl getPreChangeDist(){
    return this.preChangeDist;
}
 
开发者ID:ahaque-utd,项目名称:ECHO,代码行数:4,代码来源:CusumElement.java

示例10: getPostChangeDist

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public BetaDistributionImpl getPostChangeDist(){
    return this.postChangeDist;
}
 
开发者ID:ahaque-utd,项目名称:ECHO,代码行数:4,代码来源:CusumElement.java

示例11: setPreChangeDist

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void setPreChangeDist(BetaDistributionImpl preChangeDist){
    this.preChangeDist = preChangeDist;
}
 
开发者ID:ahaque-utd,项目名称:ECHO,代码行数:4,代码来源:CusumElement.java

示例12: setPostChangeDist

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void setPostChangeDist(BetaDistributionImpl postChangeDist){
    this.postChangeDist = postChangeDist;
}
 
开发者ID:ahaque-utd,项目名称:ECHO,代码行数:4,代码来源:CusumElement.java

示例13: detectChange

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public int/*estimated change point*/ detectChange() throws Exception
{
	int estimatedChangePoint = -1;
    int N = this.dynamicWindow.size();
    this.cushion = Math.max(100, (int)Math.floor(Math.pow(N, gamma)));
    //mean conf. should not fall below 0.3
    if(N>(2*this.cushion) && calculateMean(0, N-1) <= 0.3)
        return N-1;
    double threshold = -Math.log(this.sensitivity);
    
    double w = 0;
    int kAtMaxW = -1;
    for(int k = this.cushion; k <= N-this.cushion; k++)
    {
        if(calculateMean(k, N-1) <= 0.95*calculateMean(0, k-1))
        {
            double skn = 0;
            /* estimate pre and post change parameters */
            double alphaPreChange = calcBetaDistAlpha(0, k-1);
            double betaPreChange = calculateBetaDistBeta(alphaPreChange, 0, k-1);
            double alphaPostChange = calcBetaDistAlpha(k, N-1);
            double betaPostChange = calculateBetaDistBeta(alphaPostChange, k, N-1);
            
            BetaDistributionImpl preBetaDist = new BetaDistributionImpl(alphaPreChange, betaPreChange);
            BetaDistributionImpl postBetaDist = new BetaDistributionImpl(alphaPostChange, betaPostChange);

            for(int i=k; i<N; i++)
            {
                try{
                    skn += Math.log(postBetaDist.density(this.dynamicWindow.get(i).doubleValue())/preBetaDist.density(this.dynamicWindow.get(i).doubleValue()));
                }
                catch(Exception e){
                    e.printStackTrace();
                    System.out.println("continuing...");
                    skn = 0;
                    break;
                }
            }        
            if(skn > w)
            {
                w = skn;
                kAtMaxW = k;
            }
        }
    }
    if(w >= threshold && kAtMaxW != -1)
    {
        System.out.println("\nChangePoint Found!");
        estimatedChangePoint = kAtMaxW;
        System.out.println("Estimated change point is " + estimatedChangePoint);
    }
    //force change point if confidence falls down terribly
    if(estimatedChangePoint == -1 && N>=100 && calculateMean(0, N-1) < 0.3)
        estimatedChangePoint = N-1;
    return estimatedChangePoint;
}
 
开发者ID:ahaque-utd,项目名称:SAND,代码行数:57,代码来源:BetaDistributionChangePoint.java

示例14: RecoveryRateModelStochastic

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public RecoveryRateModelStochastic(final double a, final double b, final double x) {

    super(0.0);

    _a = a;
    _b = b;

    _x = x;

    BetaDistributionImpl betaDistribution = new BetaDistributionImpl(_a, _b);

    // FIXME : Fix this
    _recoveryRate = 0.0; //betaDistribution.inverseCumulativeProbability(_x);

    _recoveryRateType = RecoveryRateType.STOCHASTIC;

    // ----------------------------------------------------------------------------------------------------------------------------------------
  }
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:RecoveryRateModelStochastic.java

示例15: BetaIntegrator

import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public BetaIntegrator(double alpha, double beta, int pathSteps) {
    super(pathSteps);
    this.betaDistribution = new BetaDistributionImpl(alpha, beta);
}
 
开发者ID:beast-dev,项目名称:beast-mcmc,代码行数:5,代码来源:MarginalLikelihoodEstimator.java


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