本文整理汇总了Java中gnu.trove.map.TObjectDoubleMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleMap.put方法的具体用法?Java TObjectDoubleMap.put怎么用?Java TObjectDoubleMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TObjectDoubleMap
的用法示例。
在下文中一共展示了TObjectDoubleMap.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fuseObjectScoreIntoSegments
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
private static void fuseObjectScoreIntoSegments(TObjectDoubleMap<String> scoreBySegmentId,
double objectScore, List<SegmentDescriptor> segments) {
boolean objectSegmentsFoundInResults = false;
for (SegmentDescriptor segment : segments) {
boolean foundElement = scoreBySegmentId.adjustValue(segment.getSegmentId(), objectScore);
if (foundElement) {
objectSegmentsFoundInResults = true;
}
}
if (!objectSegmentsFoundInResults) {
SegmentDescriptor firstSegment = segments.get(0);
String firstId = firstSegment.getSegmentId();
scoreBySegmentId.put(firstId, objectScore);
}
}
示例2: testFromJuelSpecificationWithImport
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
@Test
public void testFromJuelSpecificationWithImport() {
String specification = "{" +
"\"in\":2," +
"\"out\":1," +
"\"import\":[\"numIterations\"]," +
"\"p\":0.8," +
"\"cpu\":\"${(3*in0 + 2*in1 + 7*out0) * numIterations}\"," +
"\"ram\":\"${6*in0 + 4*in1 + 14*out0}\"," +
"\"overhead\":143," +
"\"ru\":\"${rheem:logGrowth(0.1, 0.1, 10000, in0+in1)}\"" +
"}";
final NestableLoadProfileEstimator estimator =
LoadProfileEstimators.createFromSpecification(null, specification);
SomeExecutionOperator execOp = new SomeExecutionOperator();
TObjectDoubleMap<String> properties = new TObjectDoubleHashMap<>();
properties.put("numIterations", 2d);
final LoadProfile estimate = estimator.estimate(new SimpleEstimationContext(
new CardinalityEstimate[]{
new CardinalityEstimate(10, 10, 1d), new CardinalityEstimate(100, 100, 1d)
},
new CardinalityEstimate[]{new CardinalityEstimate(200, 300, 1d)},
properties,
1
));
Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01);
Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01);
Assert.assertEquals(
OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10),
estimate.getResourceUtilization(),
0.000000001
);
Assert.assertEquals(143, estimate.getOverheadMillis());
}
示例3: testMathExFromSpecificationWithImport
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
@Test
public void testMathExFromSpecificationWithImport() {
String specification = "{" +
"\"type\":\"mathex\"," +
"\"in\":2," +
"\"out\":1," +
"\"import\":[\"numIterations\"]," +
"\"p\":0.8," +
"\"cpu\":\"(3*in0 + 2*in1 + 7*out0) * numIterations\"," +
"\"ram\":\"6*in0 + 4*in1 + 14*out0\"," +
"\"overhead\":143," +
"\"ru\":\"logGrowth(0.1, 0.1, 10000, in0+in1)\"" +
"}";
final NestableLoadProfileEstimator estimator =
LoadProfileEstimators.createFromSpecification(null, specification);
SomeExecutionOperator execOp = new SomeExecutionOperator();
TObjectDoubleMap<String> properties = new TObjectDoubleHashMap<>();
properties.put("numIterations", 2d);
final LoadProfile estimate = estimator.estimate(new SimpleEstimationContext(
new CardinalityEstimate[]{
new CardinalityEstimate(10, 10, 1d), new CardinalityEstimate(100, 100, 1d)
},
new CardinalityEstimate[]{new CardinalityEstimate(200, 300, 1d)},
properties,
1
));
Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 200) * execOp.getNumIterations(), estimate.getCpuUsage().getLowerEstimate(), 0.01);
Assert.assertEquals((3 * 10 + 2 * 100 + 7 * 300) * execOp.getNumIterations(), estimate.getCpuUsage().getUpperEstimate(), 0.01);
Assert.assertEquals(
OptimizationUtils.logisticGrowth(0.1, 0.1, 10000, 100 + 10),
estimate.getResourceUtilization(),
0.000000001
);
Assert.assertEquals(143, estimate.getOverheadMillis());
}
示例4: getPosteriorProbabilities
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
public TObjectDoubleMap<STATES> getPosteriorProbabilities() {
TObjectDoubleMap<STATES> stateToLogPriorProbabilityAndProductIncomingMessages =
this.getStateToLogPriorProbabilityAndProductIncomingMessages();
// If we uncomment the following lines of code -
// Hamming Code Recovery via Belief Propagation will reconstruct
// correctly even parity-check bits. Otherwise - only payload bits are
// recovered correctly.
// TODO: investigate the reason of this observation.
//
// for (STATES s :
// stateToLogPriorProbabilityAndProductIncomingMessages.keySet()) {
// if
// (!stateToLogPriorProbabilityAndProductIncomingMessages.adjustValue(s,
// -0.3 * this.getLogPriorProbablility(s))) {
// throw new RuntimeException();
// }
// }
// normalize
double sum = Edge.logOfSum(stateToLogPriorProbabilityAndProductIncomingMessages.values());
for (STATES state : stateToLogPriorProbabilityAndProductIncomingMessages.keySet()) {
stateToLogPriorProbabilityAndProductIncomingMessages.put(state, Math.exp(stateToLogPriorProbabilityAndProductIncomingMessages.get(state) - sum));
}
return stateToLogPriorProbabilityAndProductIncomingMessages;
}
示例5: getStateToLogPriorProbabilityAndProductIncomingMessages
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
public TObjectDoubleMap<STATES> getStateToLogPriorProbabilityAndProductIncomingMessages() {
TObjectDoubleMap<STATES> stateToLogPriorProbabilityAndProductIncomingMessages = new TObjectDoubleHashMap<>();
for (STATES state : this.getStates()) {
double logProductOfIncomingMessages = 0;
for (Edge<?, ?> edge : this.edges) {
logProductOfIncomingMessages += edge.getLogIncomingMessage(this, state);
}
stateToLogPriorProbabilityAndProductIncomingMessages.put(state,
this.getLogPriorProbablility(state) + logProductOfIncomingMessages);
}
return stateToLogPriorProbabilityAndProductIncomingMessages;
}
示例6: testNormalProbability
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
@Test
public void testNormalProbability() {
TObjectDoubleMap<String> p = new TObjectDoubleHashMap<>();
p.put(KEY_MEAN, 0.0);
p.put(KEY_VARIANCE, 1.0);
p.put(KEY_STDEV, 1.0);
// Test a standard normal distribution
// Values taken from http://en.wikipedia.org/wiki/Standard_normal_table
assertWithinEpsilon(an.normalProbability(0.0, p), 0.5);
assertWithinEpsilon(an.normalProbability(0.3, p), 0.3820885780);
assertWithinEpsilon(an.normalProbability(1.0, p), 0.1587);
assertWithinEpsilon(1.0 - an.normalProbability(1.0, p), an.normalProbability(-1.0, p));
assertWithinEpsilon(an.normalProbability(-0.3, p), 1.0 - an.normalProbability(0.3, p));
// Non standard normal distribution
// p = {"name": "normal", "mean": 1.0, "variance": 4.0, "stdev": 2.0}
p.put(KEY_MEAN, 1.0);
p.put(KEY_VARIANCE, 4.0);
p.put(KEY_STDEV, 2.0);
assertWithinEpsilon(an.normalProbability(1.0, p), 0.5);
assertWithinEpsilon(an.normalProbability(2.0, p), 0.3085);
assertWithinEpsilon(an.normalProbability(3.0, p), 0.1587);
assertWithinEpsilon(an.normalProbability(3.0, p), 1.0 - an.normalProbability(-1.0, p));
assertWithinEpsilon(an.normalProbability(0.0, p), 1.0 - an.normalProbability(2.0, p));
// Non standard normal distribution
// p = {"name": "normal", "mean": -2.0, "variance": 0.5, "stdev": math.sqrt(0.5)}
p.put(KEY_MEAN, -2.0);
p.put(KEY_VARIANCE, 0.5);
p.put(KEY_STDEV, Math.sqrt(0.5));
assertWithinEpsilon(an.normalProbability(-2.0, p), 0.5);
assertWithinEpsilon(an.normalProbability(-1.5, p), 0.241963652);
assertWithinEpsilon(an.normalProbability(-2.5, p), 1.0 - an.normalProbability(-1.5, p));
}
示例7: testSampleDistribution
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
/**
* Test that sampleDistribution from a generated distribution returns roughly
* the same parameters.
*/
@Test
public void testSampleDistribution() {
TObjectDoubleMap<String> p = new TObjectDoubleHashMap<>();
p.put(KEY_MEAN, 0.5);
p.put(KEY_STDEV, Math.sqrt(0.1));
p.put(KEY_VARIANCE, 0.1);
double[] samples = sampleDistribution(new MersenneTwister(), 0.5, 0.1, 1000);
Statistic np = an.estimateNormal(samples, true);
assertTrue(assertWithinEpsilon(p.get(KEY_MEAN), np.mean, 0.1));
assertTrue(assertWithinEpsilon(p.get(KEY_VARIANCE), np.variance, 0.1));
assertTrue(assertWithinEpsilon(p.get(KEY_STDEV), np.stdev, 0.1));
}
示例8: buildEntityFitnessMap
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
public static <E> TObjectDoubleMap<E> buildEntityFitnessMap(
List<E> entities, Function<E, Double> entityFitnessFunction) {
TObjectDoubleMap<E> fitnessMap = new TObjectDoubleHashMap<>();
for (E entity : entities) {
fitnessMap.put(entity, entityFitnessFunction.apply(entity));
}
return fitnessMap;
}