本文整理汇总了Java中cern.jet.random.Uniform类的典型用法代码示例。如果您正苦于以下问题:Java Uniform类的具体用法?Java Uniform怎么用?Java Uniform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Uniform类属于cern.jet.random包,在下文中一共展示了Uniform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AntColonyOptimisation
import cern.jet.random.Uniform; //导入依赖的package包/类
/**
*
* @param arg_file
* @throws IOException
*/
public AntColonyOptimisation(Properties prop, int runNum) throws IOException
{
//rep = new Representation();
//TSP_FILE = arg_file;
p = prop;
run = runNum;
// read the matrix
matrix = (new TSP()).readMatrixFromFile(prop);
/* testing ajecency matrix
for(double j []: matrix)
{
for(double i : j)
{
System.out.print(i +" ");
} System.out.println();
}
*/
invertedMatrix = invertMatrix();
pheromones = initializePheromones();
mutexes = initializeMutexObjects();
uniform = new Uniform(0, matrix.length - 1,(int) System.currentTimeMillis());
}
示例2: uniform_rnd
import cern.jet.random.Uniform; //导入依赖的package包/类
public static double uniform_rnd() {
return Uniform.staticNextDouble();
}
示例3: multinomial_rnd
import cern.jet.random.Uniform; //导入依赖的package包/类
public static int multinomial_rnd(double[] p, int vSize) {
double sum = 0.0;
double mass = 0.0;
int cc = 0;
int i = 0;
for (i=0;i<vSize;i++) {
sum += p[i];
}
mass = Uniform.staticNextDouble() * sum;
i = 0;
while (true) {
mass -= p[i];
if (mass <= 0.0) break;
i++;
cc++;
}
return cc;
}
示例4: randPerm
import cern.jet.random.Uniform; //导入依赖的package包/类
/**
*
* @param n
* @return
*/
public static int[] randPerm(int n) {
int[] order = new int[n];
ArrayList<Integer> nm = new ArrayList<Integer>();
int i = 0;
for (i=0;i<n;i++) {
nm.add(i);
}
int c = 0;
for (i=n-1;i>=0;i--) {
if (i > 0) {
c = Uniform.staticNextIntFromTo(0,i);
} else {
c = 0;
}
order[i] = nm.get(c);
nm.remove(c);
}
return order;
//Uniform.staticNextIntFromTo(0,numClusters-1);
}
示例5: train
import cern.jet.random.Uniform; //导入依赖的package包/类
@Override
public void train(List<? extends Annotated<OBJECT, ANNOTATION>> data) {
final HashSet<ANNOTATION> annotationsSet = new HashSet<ANNOTATION>();
final TIntIntHashMap nAnnotationCounts = new TIntIntHashMap();
int maxVal = 0;
for (final Annotated<OBJECT, ANNOTATION> sample : data) {
final Collection<ANNOTATION> annos = sample.getAnnotations();
annotationsSet.addAll(annos);
nAnnotationCounts.adjustOrPutValue(annos.size(), 1, 1);
if (annos.size() > maxVal)
maxVal = annos.size();
}
annotations = new ArrayList<ANNOTATION>(annotationsSet);
rnd = new Uniform(0, annotations.size() - 1, new MersenneTwister());
numAnnotations.train(data);
}
示例6: test2Floats
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void test2Floats()
{
for(int i=0; i<100; i++){
double[] input = new double[]{
Uniform.staticNextDoubleFromTo(-10, 10),
Uniform.staticNextDoubleFromTo(-10, 10)
};
double[] result = {input[0], 1, input[1]};
double[] parsed = RangeParser.parse("["+input[0]+":"+input[1]+"]");
assertArrayEquals(parsed, result);
}
}
示例7: testDenseDoubleMatrix1D
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void testDenseDoubleMatrix1D()
{
DenseDoubleMatrix1D a = new DenseDoubleMatrix1D(new double[]{
Uniform.staticNextDouble(),Uniform.staticNextDouble(),Uniform.staticNextDouble()
});
DenseDoubleMatrix1D b = new DenseDoubleMatrix1D(new double[]{
Uniform.staticNextDouble(),Uniform.staticNextDouble(),Uniform.staticNextDouble()
});
DoubleMatrix1D c = a.copy();
FeatureCache cache = new FeatureCache(10);
cache.put(a, null);
assertTrue(cache.containsKey(a));
assertFalse(cache.containsKey(b));
assertTrue(cache.containsKey(c));
}
示例8: doAction
import cern.jet.random.Uniform; //导入依赖的package包/类
/**
* Perform action
* @param a The action
*/
public double doAction(Action a)
{
// calc reward
if(a.equals(THROW)){
int result = Uniform.staticNextIntFromTo(1,6);
if(result > 1){
s.set(0, s.get(0) + result);
}
else{
s.set(0,0);
term = true;
}
return 0;
}
else{ // STOP
term = true;
return s.get(0);
}
}
示例9: setUp
import cern.jet.random.Uniform; //导入依赖的package包/类
public void setUp() {
prng = new MersenneTwister64(PRNGTestSeeds.UNIT_TEST_SEED);
auction = new MarketSimulation();
SimulationController controller = new SpringSimulationController();
auction.setSimulationController(controller);
auction.setPopulation(new Population());
auction.setAgentMixer(new RandomRobinAgentMixer(prng));
auction.setAgentInitialiser(new BasicAgentInitialiser());
auctioneer = new ClearingHouseAuctioneer(auction);
auction.setAuctioneer(auctioneer);
testAgent = new TokenTradingAgent(PRIV_VALUE, 100, controller);
Uniform distribution = new Uniform(0, MAX_PRICE, prng);
testStrategy = new RandomUnconstrainedStrategy(distribution, testAgent);
testStrategy.setBuy(false);
testAgent.setStrategy(testStrategy);
logger = new PriceStatisticsReport();
// auction.addReport(logger);
controller.addListener(logger);
auction.register(testAgent);
auction.setMaximumRounds(MAX_ROUNDS);
}
示例10: setUp
import cern.jet.random.Uniform; //导入依赖的package包/类
public void setUp() {
prng = new MersenneTwister64(PRNGTestSeeds.UNIT_TEST_SEED);
this.auction = new MarketSimulation();
SimulationController controller = new SpringSimulationController();
auction.setSimulationController(controller);
auction.setPopulation(new Population());
auction.setAgentMixer(new RandomRobinAgentMixer(prng));
auction.setAgentInitialiser(new BasicAgentInitialiser());
testAgent = new TokenTradingAgent(PRIV_VALUE, 100, controller);
testStrategy = new RandomConstrainedStrategy(testAgent);
testStrategy.setBuy(false);
testStrategy.setMarkupDistribution(new Uniform(0, MAX_MARKUP, prng));
testAgent.setStrategy(testStrategy);
auctioneer = new ClearingHouseAuctioneer(auction);
auction.setAuctioneer(auctioneer);
report = new PriceStatisticsReport();
// auction.addReport(report);
controller.addListener(report);
auction.register(testAgent);
auction.setMaximumRounds(MAX_ROUNDS);
}
示例11: RandomNumberGenerator
import cern.jet.random.Uniform; //导入依赖的package包/类
/**
* Create a new random number generator (seeded, by default, with the current time).
*/
public RandomNumberGenerator()
{
random = new MersenneTwister(new Date());
uniform = new Uniform(random);
// Create exponential generator (rate 1.0 but this is ignored from now on)
exponential = new Exponential(1.0, random);
}
示例12: testFrequencyAndDepositSuccess
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void testFrequencyAndDepositSuccess() {
final RandomHousehold rh = new RandomHousehold( bank, new Uniform( 0.0, 1.0, 0 ), 1, 9, 1 );
rh.step( simState );
assertTrue( 1.0 <= rh.getDepositValue() && rh.getDepositValue() <= 10.0 );
}
示例13: testFrequencyAndWithdrawalSuccess
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void testFrequencyAndWithdrawalSuccess() {
final RandomHousehold rh = new RandomHousehold( bank, new Uniform( 0.0, 1.0, 0 ), 1, 9, - 10 );
rh.debit( 20 );
rh.step( simState );
assertTrue( 10.0 <= rh.getDepositValue() && rh.getDepositValue() <= 20.0 );
}
示例14: testFrequencyAndWithdrawalFailureEmpties
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void testFrequencyAndWithdrawalFailureEmpties() {
final RandomHousehold rh = new RandomHousehold( bank, new Uniform( 0.0, 1.0, 0 ), 1, 9, - 10 );
rh.step( simState );
assertEquals( rh.getDepositValue(), 0.0, TestConstants.DELTA );
}
示例15: testFrequencyFailure
import cern.jet.random.Uniform; //导入依赖的package包/类
@Test
public void testFrequencyFailure() {
final RandomHousehold rh = new RandomHousehold( bank, new Uniform( 0.0, 1.0, 0 ), 0, 9, 1 );
rh.step( simState );
assertEquals( rh.getDepositValue(), 0.0, TestConstants.DELTA );
}