本文整理汇总了Java中cern.jet.random.Uniform.staticNextDoubleFromTo方法的典型用法代码示例。如果您正苦于以下问题:Java Uniform.staticNextDoubleFromTo方法的具体用法?Java Uniform.staticNextDoubleFromTo怎么用?Java Uniform.staticNextDoubleFromTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.jet.random.Uniform
的用法示例。
在下文中一共展示了Uniform.staticNextDoubleFromTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: test3Floats
import cern.jet.random.Uniform; //导入方法依赖的package包/类
@Test
public void test3Floats()
{
for(int i=0; i<100; i++){
double[] input = new double[]{
Uniform.staticNextDoubleFromTo(-10, 10),
Uniform.staticNextDoubleFromTo(-10, 10),
Uniform.staticNextDoubleFromTo(-10, 10)
};
double[] parsed = RangeParser.parse("["+input[0]+":"+input[1]+":"+input[2]+"]");
assertArrayEquals(parsed, input);
}
}
示例3: createTiling
import cern.jet.random.Uniform; //导入方法依赖的package包/类
public static List<Tile> createTiling(double[][] config, boolean shiftRandomly) {
/** For example, if we have an 2 dim. statespace
* each in [0,1] and we want to divide the
* first dim. in 5 parts and the second dim. 20 parts
* then the config. should look like this:
*
* <pre>
* double[][] config = new double[][] {
* { 0, 1, 5 }, // fst dim.
* { 0, 1, 20 } // snd. dim.
* };
* </pre>
*
* @param config The configuration
*/
List<Tile> tiles = new LinkedList<Tile>();
double[] tilePosition = new double[config.length];
double[] tileWidths = new double[config.length];
double[] offset = new double[config.length];
double[] minTilePosition = new double[config.length];
double[] maxTilePosition = new double[config.length];
for (int dim = 0; dim < config.length; dim++) {
// calculate the widths for a tile in each dimension and an offset
// in each dimension used for all tiles
tileWidths[dim] = (config[dim][1] - config[dim][0])
/ config[dim][2];
// only shift tilings randomly if disired
if (shiftRandomly)
offset[dim] = Uniform.staticNextDoubleFromTo(-tileWidths[dim],
tileWidths[dim]);
else
offset[dim] = 0;
// initialze minPosition, maxPosition
minTilePosition[dim] = config[dim][0] + tileWidths[dim]/2 + offset[dim];
maxTilePosition[dim] = config[dim][1] + offset[dim];
}
tilePosition = minTilePosition.clone();
while (true) {
tiles.add(new Tile(tilePosition, tileWidths));
if (!incrementTilePosition(tilePosition, minTilePosition,
maxTilePosition, tileWidths))
break;
}
return tiles;
}