本文整理汇总了Java中org.apache.commons.math3.distribution.AbstractRealDistribution类的典型用法代码示例。如果您正苦于以下问题:Java AbstractRealDistribution类的具体用法?Java AbstractRealDistribution怎么用?Java AbstractRealDistribution使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractRealDistribution类属于org.apache.commons.math3.distribution包,在下文中一共展示了AbstractRealDistribution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDayMockDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public static AbstractRealDistribution createDayMockDistribution(final int seed) {
final EmpiricalDistribution dayDistributionMock = new EmpiricalDistribution(new Well19937c(seed));
int[] demandsOverDay = new int[]{/* 0 */9,/* 1 */6,/* 2 */6,
/* 3 */6,/* 4 */7,/* 5 */12,/* 6 */25,/* 7 */37,/* 8 */49,
/* 9 */38,/* 10 */30,/* 11 */30,/* 12 */30,/* 13 */30,/* 14 */31,
/* 15 */36,/* 16 */45,/* 17 */41,/* 18 */31,/* 19 */27,/* 20 */25,/* 21 */22,/* 22 */18,/* 23 */11};
List<Double> dayHourDistribution = Lists.newArrayList();
int day = 0;
for (int demand : demandsOverDay) {
double hourInMillis = Duration.standardHours(day).getMillis();
for (int i = 0; i < demand; i++) {
dayHourDistribution.add(hourInMillis);
}
day++;
}
dayDistributionMock.load(Doubles.toArray(dayHourDistribution));
return dayDistributionMock;
}
示例2: HypothesesTest
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public HypothesesTest(DistributionStatistics a_a,
DistributionStatistics a_b, double a_alpha, double a_beta,
boolean a_tailed,
AbstractRealDistribution a_abstractRealDistribution) {
a = a_a;
b = a_b;
alpha = a_alpha;
beta = a_beta;
tailed = a_tailed;
abstractRealDistribution = a_abstractRealDistribution;
}
示例3: sample
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public double sample(final RandomGenerator rng, final Function<Double, Double> logPDF) {
Utils.nonNull(rng);
Utils.nonNull(logPDF);
final AbstractRealDistribution normal = new NormalDistribution(rng, 0, 1);
final double proposal = xCurrent + stepSize * normal.sample();
final double acceptanceProbability = (proposal < lowerBound || upperBound < proposal) ? 0
: Math.min(1, Math.exp(logPDF.apply(proposal) - logPDF.apply(xCurrent)));
//adjust stepSize larger/smaller to decrease/increase the acceptance rate
final double correctionFactor = (acceptanceProbability - optimalAcceptanceRate) * adjustmentRate * (timeScale / (timeScale + iteration));
stepSize *= Math.exp(correctionFactor);
iteration++;
return rng.nextDouble() < acceptanceProbability ? proposal : xCurrent;
}
示例4: getAssignmentArray
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
/**
* Generates an assignment balls to bins according to the
* given distribution. The i-th position of the array represents
* the number of balls to assign to the i-th bin.
* @param bins
* @param balls
* @param distribution
* @return
*/
public static int[] getAssignmentArray(int bins, int balls, AbstractRealDistribution distribution)
{
// generates and sort samples from the distribution
double[] samples = distribution.sample(balls);
Arrays.sort(samples);
// manage the samples bounds
double min = samples[0];
double max = samples[samples.length - 1];
double delta = (max - min) / bins;
// generate the assignment
int[] ass = new int[bins];
int z = 0;
for (int i=0; i<ass.length; i++)
{
double threshold = min + (delta * (i+1));
while (z <samples.length && samples[z] <= threshold)
{
ass[i]++;
z++;
}
}
return ass;
}
示例5: getApplication
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
/**
* Return an application whose cloudlets are assigned to vertex with
* a custom distribution.
* @param userId
* @param numVertex
* @param numCloudlet
* @return
*/
public Application getApplication(int userId, int numVertex, int numCloudlet, AbstractRealDistribution distribution)
{
if (numCloudlet < numVertex)
throw new Error("Cannot create an application with more vertexes ("+numVertex+") than cloudlets ("+numCloudlet+")");
int[] assignment = DistributionAssignment.getAssignmentArray(numVertex, numCloudlet, distribution);
return getApplication(userId, assignment);
}
示例6: createDayMockDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public static AbstractRealDistribution createDayMockDistribution(final int seed) {
int intermediateStepsCount = 60;
final EmpiricalDistribution dayDistributionMock = new EmpiricalDistribution(24 * intermediateStepsCount, new Well19937c(seed));
int[] demandsOverDay = new int[]{/* 0 */9,/* 1 */6,/* 2 */6,
/* 3 */6,/* 4 */7,/* 5 */12,/* 6 */25,/* 7 */37,/* 8 */49,
/* 9 */38,/* 10 */30,/* 11 */30,/* 12 */30,/* 13 */30,/* 14 */31,
/* 15 */36,/* 16 */45,/* 17 */41,/* 18 */31,/* 19 */27,/* 20 */25,/* 21 */22,/* 22 */18,/* 23 */11};
List<Double> dayHourDistribution = Lists.newArrayList();
int hour = 0;
for (int i = 0; i < demandsOverDay.length - 1; ++i) {
double startHourInMillis = Duration.standardHours(hour).getMillis();
double endHourInMillis = Duration.standardHours(hour + 1).getMillis();
double demandsStep = ((double) (demandsOverDay[hour] -
demandsOverDay[(hour + 1) % 24])) / intermediateStepsCount;
double timeStep = (endHourInMillis - startHourInMillis) / intermediateStepsCount;
for (int j = 0; j < intermediateStepsCount; ++j) {
int demands = (int) (demandsOverDay[i] + demandsStep * j);
for (int k = 0; k < demands; ++k)
dayHourDistribution.add(startHourInMillis + j * timeStep);
}
hour++;
}
dayDistributionMock.load(Doubles.toArray(dayHourDistribution));
return dayDistributionMock;
}
开发者ID:agents4its,项目名称:mobilitytestbed,代码行数:37,代码来源:PassengerGeneratorWithContinousRequestCallTimeDistribution.java
示例7: LenientPassengerGenerator
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public LenientPassengerGenerator(AbstractRealDistribution dayDistribution, Random random,
LenientRequestGenerator generator, String osmFileName, String benchmarkDir) {
super();
this.dayDistribution = dayDistribution;
this.random = random;
this.benchmarkDir = benchmarkDir;
this.generator = createGPSPositionGenerator(new File(osmFileName), generator.getPositionGeneratorFactory());
Injector injector = createInjector(this.benchmarkDir, new File(osmFileName));
this.utils = injector.getInstance(Utils.class);
this.nearestNodeFinder = injector.getInstance(NodeExtendedFunction.class);
// this.sampleNodesList = null;
// this.averageDrivingTimeBetweenSamples = 0;
this.sampleNodesList = generateSamples();
this.averageDrivingTimeBetweenSamples = calculateAverageDrivingTimeBetweenSamples();
}
示例8: test
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
@Test
public void test() {
AbstractRealDistribution createDayMockDistribution = PassengerGeneratorImpl.createDayMockDistribution(0);
for (int i = 0; i < 1000; i++) {
long time = (long) createDayMockDistribution.sample();
assertTrue(time >= 0 && time <= Duration.standardHours(23).getMillis());
}
}
示例9: StochasticTimeBehavior
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public StochasticTimeBehavior(AbstractRealDistribution distribution) {
this.distribution = distribution;
}
示例10: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
public AbstractRealDistribution getDistribution() {
return distribution;
}
示例11: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
@Override
public AbstractRealDistribution getDistribution() {
return new GammaDistribution(params[0], params[1]);
}
示例12: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
@Override
public AbstractRealDistribution getDistribution() {
return new UniformRealDistribution(params[0], params[1]);
}
示例13: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
/** return distribution for given transition or null if not applicable **/
public AbstractRealDistribution getDistribution();
示例14: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
@Override
public AbstractRealDistribution getDistribution() {
return new ExponentialDistribution(params[0]);
}
示例15: getDistribution
import org.apache.commons.math3.distribution.AbstractRealDistribution; //导入依赖的package包/类
@Override
public AbstractRealDistribution getDistribution() {
return new NormalDistribution(params[0], params[1]);
}