本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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());
}
}
示例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);
}
示例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);
}
示例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;
}
示例9: getPreChangeDist
import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public BetaDistributionImpl getPreChangeDist(){
return this.preChangeDist;
}
示例10: getPostChangeDist
import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public BetaDistributionImpl getPostChangeDist(){
return this.postChangeDist;
}
示例11: setPreChangeDist
import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void setPreChangeDist(BetaDistributionImpl preChangeDist){
this.preChangeDist = preChangeDist;
}
示例12: setPostChangeDist
import org.apache.commons.math.distribution.BetaDistributionImpl; //导入依赖的package包/类
public void setPostChangeDist(BetaDistributionImpl postChangeDist){
this.postChangeDist = postChangeDist;
}
示例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;
}
示例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;
// ----------------------------------------------------------------------------------------------------------------------------------------
}
示例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);
}