package Lec11;
import java.io.*;
import java.util.*;
/*
繰り返しデータをファイル出力します.
outputFileNameにcsvファイル名を入れ,
生成したデータをcsv形式で保存します.
*/
public class CalculatedDataOutput02 { //課題で変更
//Iteration回数:Imax
public static final int Imax = 100000;
public static final double Mean = 1.0; //課題で追加
public static final double StandardDeviation = 0.7; //課題で追加
public static void main
(String[] args
) { try {
//②’(シンプル)データを保存するcsvファイル名を入力する
System.
out.
print("Please give me an Output File Name (no need .csv): "); //課題で追加 String outputFileName
= buffIn.
readLine() + ".csv"; //課題で追加
//③BufferedWriterクラスのインスタンスを生成し
//参照型変数 pw に代入する.
//読み込むファイルを FileWriter() で初期化する.
//BoxMullerMethod bm_def = new BoxMullerMethod();//平均0,標準偏差1
//BoxMullerMethod bm = new BoxMullerMethod(10,25);//平均10,標準偏差25
double y;
//Imax個のデータを生成する
for (int i = 1; i <= Imax; i++) {
//Box-Muller method
//y = bm_def.normRand();
//正規乱数Norm(0,1)を生成するメソッド
y = Mean + StandardDeviation * rnd.nextGaussian(); //課題で変更
//④データの出力の仕方を選ぶ
pw.write(y + "\r\n"); //[データのみ] 1行
//pw.write(i + "," + y + "\r\n"); //[データ番号, データ] 2行
}
pw.close();//ファイルを閉じる
// Fileオブジェクト生成時の例外捕捉
e.printStackTrace();
// BufferedReaderオブジェクトのクローズ時の例外捕捉
e.printStackTrace();
}
}
}
cGFja2FnZSBMZWMxMTsKCmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuKjsKCi8qCiDnubDjgorov5TjgZfjg4fjg7zjgr/jgpLjg5XjgqHjgqTjg6vlh7rlipvjgZfjgb7jgZnvvI4KIG91dHB1dEZpbGVOYW1l44GrY3N244OV44Kh44Kk44Or5ZCN44KS5YWl44KM77yMCiDnlJ/miJDjgZfjgZ/jg4fjg7zjgr/jgpJjc3blvaLlvI/jgafkv53lrZjjgZfjgb7jgZnvvI4KICovCnB1YmxpYyBjbGFzcyBDYWxjdWxhdGVkRGF0YU91dHB1d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oDjg5XjgqHjgqTjg6vjgpIgRmlsZVdyaXRlcigpIOOBp+WIneacn+WMluOBmeOCi++8jgogICAgICAgICAgICBQcmludFdyaXRlciBwdyA9CiAgICAgICAgICAgICAgICAgICAgbmV3IFByaW50V3JpdGVyKG5ldyBCdWZmZXJlZFdyaXRlcihuZXcgRmlsZVdyaXRlcihvdXRwdXRGaWxlTmFtZSkpKTsKCiAgICAgICAgICAgIC8vQm94TXVsbGVyTWV0aG9kIGJtX2RlZiA9IG5ldyBCb3hNdWxsZXJNZXRob2QoKTsvL+W5s+Wdh++8kO+8jOaomea6luWBj+W3ru+8kQogICAgICAgICAgICAvL0JveE11bGxlck1ldGhvZCBibSA9IG5ldyBCb3hNdWxsZXJNZXRob2QoMTAsMjUpOy8v5bmz5Z2HMTDvvIzmqJnmupblgY/lt64yNQoKICAgICAgICAgICAgZG91YmxlIHk7CiAgICAgICAgICAgIFJhbmRvbSBybmQgPSBuZXcgUmFuZG9tKCk7CgogICAgICAgICAgICAvL0ltYXjlgIvjga7jg4fjg7zjgr/jgpLnlJ/miJDjgZnjgosKICAgICAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gSW1heDsgaSsrKSB7CgogICAgICAgICAgICAgICAgLy9Cb3gtTXVsbGVyIG1ldGhvZAogICAgICAgICAgICAgICAgLy95ID0gYm1fZGVmLm5vcm1SYW5kKCk7CiAgICAgICAgICAgICAgICAvL+ato+imj+S5seaVsE5vcm0oMCwxKeOCkueUn+aIkOOBmeOCi+ODoeOCveODg+ODiQogICAgICAgICAgICAgICAgeSA9IE1lYW4gKyBTdGFuZGFyZERldmlhdGlvbiAqIHJuZC5uZXh0R2F1c3NpYW4oKTsgLy/oqrLpoYzjgaflpInmm7QKCiAgICAgICAgICAgICAgICAvL+KRo+ODh+ODvOOCv+OBruWHuuWKm+OBruS7leaWueOCkumBuOOBtgogICAgICAgICAgICAgICAgcHcud3JpdGUoeSArICJcclxuIik7ICAgIAkJCS8vW+ODh+ODvOOCv+OBruOBv13jgIAx6KGMCiAgICAgICAgICAgICAgICAvL3B3LndyaXRlKGkgKyAiLCIgKyB5ICsgIlxyXG4iKTsJLy9b44OH44O844K/55Wq5Y+3LCDjg4fjg7zjgr9d44CAMuihjAogICAgICAgICAgICB9CiAgICAgICAgICAgIHB3LmNsb3NlKCk7Ly/jg5XjgqHjgqTjg6vjgpLplonjgZjjgosKCiAgICAgICAgfSBjYXRjaCAoRmlsZU5vdEZvdW5kRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgLy8gRmlsZeOCquODluOCuOOCp+OCr+ODiOeUn+aIkOaZguOBruS+i+WkluaNleaNiQogICAgICAgICAgICBlLnByaW50U3RhY2tUcmFjZSgpOwogICAgICAgIH0gY2F0Y2ggKElPRXhjZXB0aW9uIGUpIHsKICAgICAgICAgICAgLy8gQnVmZmVyZWRSZWFkZXLjgqrjg5bjgrjjgqfjgq/jg4jjga7jgq/jg63jg7zjgrrmmYLjga7kvovlpJbmjZXmjYkKICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICB9CiAgICB9Cn0=