当前位置: 首页>>代码示例>>Java>>正文


Java Uniform.staticNextDoubleFromTo方法代码示例

本文整理汇总了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);
            
    }
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:17,代码来源:TestRangeParser.java

示例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);

    }
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:16,代码来源:TestRangeParser.java

示例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;
}
 
开发者ID:ieugen,项目名称:Teachingbox,代码行数:50,代码来源:TileCodingFactory.java


注:本文中的cern.jet.random.Uniform.staticNextDoubleFromTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。