MersenneTwister发电机

时间:2014-07-24 10:04:15

标签: java random apache-commons-math

我正在尝试生成Mersenne Twister发生器,但我总是有按摩“MersenneTwister无法解析为一种类型” 这是我的代码

public class RandomVariable
{
  /** Initialize Mersenne Twister generator. */

  private static MersenneTwister rnd  = new MersenneTwister();

  /** Generate a uniformly distributed random number between 0 and 1.
   *
   *  @return      A double between 0 and 1.
   *
   *  </p>
   */

  public static double rand()
  {
    return rnd.nextDouble();
  }
}

1 个答案:

答案 0 :(得分:0)

您需要在Java项目类路径中包含Apache Commons Math库,并在源代码中添加以下导入行:

import org.apache.commons.math3.random.MersenneTwister;