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


Java MersenneTwisterFast.nextGaussian方法代码示例

本文整理汇总了Java中ec.util.MersenneTwisterFast.nextGaussian方法的典型用法代码示例。如果您正苦于以下问题:Java MersenneTwisterFast.nextGaussian方法的具体用法?Java MersenneTwisterFast.nextGaussian怎么用?Java MersenneTwisterFast.nextGaussian使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ec.util.MersenneTwisterFast的用法示例。


在下文中一共展示了MersenneTwisterFast.nextGaussian方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tenOptions

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptions() throws Exception
{

        //option 10 is the best, you should pick it!
        MersenneTwisterFast random = new MersenneTwisterFast();
        SoftmaxBanditAlgorithm bandit = new SoftmaxBanditAlgorithm(
                new BanditAverage(10, IterativeAverage::new), 20, .98);
        for (int i = 0; i < 2000; i++) {
            int arm = bandit.chooseArm(random);
            double reward = random.nextGaussian() / 2 + arm;
            bandit.observeReward(reward, arm);
        }

        //now you should be playing most
        System.out.println(bandit.getNumberOfObservations(9));
        //sometimes it gets stuck at 8 rather than 9
        assertTrue(bandit.getNumberOfObservations(9) + bandit.getNumberOfObservations(8)> 1000);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:21,代码来源:SoftmaxBanditAlgorithmTest.java

示例2: tenOptionsEMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsEMA() throws Exception
{


    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    SoftmaxBanditAlgorithm bandit = new SoftmaxBanditAlgorithm(
            new BanditAverage(10, () -> new ExponentialMovingAverage<>(.8)), 50, .975);
    for (int i = 0; i < 1000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    System.out.println(bandit.getNumberOfObservations(9));
    assertTrue(bandit.getNumberOfObservations(9) > 500);


}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:22,代码来源:SoftmaxBanditAlgorithmTest.java

示例3: tenOptionsMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsMA() throws Exception
{

    //About 1 out of 5000 trials fail

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    SoftmaxBanditAlgorithm bandit = new SoftmaxBanditAlgorithm(
            new BanditAverage(10, () -> new MovingAverage<>(20)), 50, .975);
    for (int i = 0; i < 1000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    System.out.println(bandit.getNumberOfObservations(9));
    assertTrue(bandit.getNumberOfObservations(9) > 500);


}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:23,代码来源:SoftmaxBanditAlgorithmTest.java

示例4: tenOptions

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptions() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    UCB1BanditAlgorithm bandit = new UCB1BanditAlgorithm(
            -10,10,new BanditAverage(10, IterativeAverage::new)) ;
    for (int i = 0; i < 10000; i++) { //notice how much slower this method is. It is being extremely cautious
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    System.out.println(bandit.getNumberOfObservations(9));
    assertTrue(bandit.getNumberOfObservations(9)>5000);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:20,代码来源:UCB1BanditAlgorithmTest.java

示例5: tenOptionsEMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsEMA() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    UCB1BanditAlgorithm bandit = new UCB1BanditAlgorithm(
            -10,10,new BanditAverage(10, () -> new ExponentialMovingAverage<>(.8))) ;

    for (int i = 0; i < 10000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    System.out.println(bandit.getNumberOfObservations(9));
    assertTrue(bandit.getNumberOfObservations(9)>4000);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:21,代码来源:UCB1BanditAlgorithmTest.java

示例6: tenOptionsMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsMA() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    UCB1BanditAlgorithm bandit = new UCB1BanditAlgorithm(
            -10,10,new BanditAverage(10, () -> new MovingAverage<>(20))) ;
    for (int i = 0; i < 10000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    System.out.println(bandit.getNumberOfObservations(9));
    assertTrue(bandit.getNumberOfObservations(9)>5000);

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:20,代码来源:UCB1BanditAlgorithmTest.java

示例7: tenOptions

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptions() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    EpsilonGreedyBanditAlgorithm bandit = new EpsilonGreedyBanditAlgorithm(
            new BanditAverage(10, IterativeAverage::new)
            , .2);
    for (int i = 0; i < 1000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    bandit.setExplorationProbability(0);
    assertEquals(9, bandit.chooseArm(random));

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:21,代码来源:EpsilonGreedyBanditAlgorithmTest.java

示例8: tenOptionsEMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsEMA() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    EpsilonGreedyBanditAlgorithm bandit = new EpsilonGreedyBanditAlgorithm(
            new BanditAverage(10, () -> new ExponentialMovingAverage<>(.8))
            , .2);
    for (int i = 0; i < 1000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    bandit.setExplorationProbability(0);
    assertEquals(9, bandit.chooseArm(random));

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:21,代码来源:EpsilonGreedyBanditAlgorithmTest.java

示例9: tenOptionsMA

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void tenOptionsMA() throws Exception
{

    //option 10 is the best, you should pick it!
    MersenneTwisterFast random = new MersenneTwisterFast();
    EpsilonGreedyBanditAlgorithm bandit = new EpsilonGreedyBanditAlgorithm(
            new BanditAverage(10, () -> new MovingAverage<>(20))
            , .2);
    for (int i = 0; i < 1000; i++) {
        int arm = bandit.chooseArm(random);
        double reward = random.nextGaussian() / 2 + arm;
        bandit.observeReward(reward, arm);
    }

    //now you should be playing most
    bandit.setExplorationProbability(0);
    assertEquals(9, bandit.chooseArm(random));

}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:21,代码来源:EpsilonGreedyBanditAlgorithmTest.java

示例10: NineBoxes

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
@Test
public void NineBoxes() throws Exception {

    SimpleMapInitializer map = new SimpleMapInitializer(50, 50, 0, 0, 1, 10);
    MersenneTwisterFast randomizer = new MersenneTwisterFast();
    NauticalMap chart = map.makeMap(randomizer,
                                    mock(GlobalBiology.class),
                                    mock(FishState.class));
    SquaresMapDiscretizer discretizer = new SquaresMapDiscretizer(2, 2);
    MapDiscretization discretization = new MapDiscretization(discretizer);
    discretization.discretize(chart);
    BanditDestinationStrategy strategy = new BanditDestinationStrategy(
            (Function<Integer, BanditAverage>) integer -> new BanditAverage(integer,
                                                                            () -> new ExponentialMovingAverage<>(.5)),
            banditAverage -> new EpsilonGreedyBanditAlgorithm(banditAverage,.1),
            discretization,
            new FavoriteDestinationStrategy(chart.getRandomBelowWaterLineSeaTile(randomizer)),
            false, false);

    //option 2 is the best, you should pick it!


    for (int i = 0; i < 1000; i++) {
        SeaTile tile = strategy.getFavoriteSpot();
        int armPlayed = discretization.getGroup(tile);
        double reward = -Math.pow(armPlayed-2,2)+randomizer.nextGaussian()/2;
        strategy.choose(tile,reward,randomizer);
    }

    ((EpsilonGreedyBanditAlgorithm) strategy.getAlgorithm()).setExplorationProbability(0);
    assertEquals(2,strategy.getAlgorithm().chooseArm(randomizer));
}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:33,代码来源:BanditDestinationStrategyTest.java

示例11: apply

import ec.util.MersenneTwisterFast; //导入方法依赖的package包/类
/**
 * Applies this function to the given argument.
 *
 * @param mersenneTwisterFast the function argument
 * @return the function result
 */
@Override
public Double apply(MersenneTwisterFast mersenneTwisterFast) {
    return mersenneTwisterFast.nextGaussian()*standardDeviation + mean;
}
 
开发者ID:CarrKnight,项目名称:POSEIDON,代码行数:11,代码来源:NormalDoubleParameter.java


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