[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
public class WhiteNoise {
protected Double average;protected Double standardDeviation;protected Random random;public WhiteNoise(Double average, Double variance) {this.average = average;this.standardDeviation = Math.sqrt(variance);this.random = new Random();}public Double calc() {return average + random.nextGaussian() * standardDeviation;}public static void main(String[] args) {WhiteNoise whiteNoise = new WhiteNoise(0d, 2d);for (int i = 0; i < 1000; i++) {System.out.println(whiteNoise.calc());}}}