public EM(File dataFile, File resFile) throws FileNotFoundException, IOException { //vZRXgN^BĂ̒ʂ̓f[^t@CƏo͐t@Cw肷B
		List<Double> dataList = new ArrayList<Double>();
		
		
		/* RTO̕1sڂɃIWiTweetURLĂ̂ŁAf[^2sڂB
		 * ẴItZbgw肵ĂƁB
		 */

		InputStreamReader isr = new InputStreamReader(new FileInputStream(dataFile));
		BufferedReader br = new BufferedReader(isr);
		String head = br.readLine(); //擪s
		
		String line = new String();
		while((line = br.readLine()) != null) {//f[^Xgɓǂݍ݁Bnullit@CjŃuCNB
			//String[] splitedLine = line.split(","); //Xvb^[̓eXgf[^ł͎gĂRTOł͎gȂ
			//dataList.add(Double.parseDouble(splitedLine[1]));
			try {
				dataList.add(Double.parseDouble(line));
			} catch(NumberFormatException e) { //DoubleɃp[XłȂςȒl烊^[ĂB
				e.printStackTrace();
				br.close();
				isr.close();
				return;
			}
		}
		br.close();
		isr.close();
			
		double[] data = new double[dataList.size()];
		int dataMin = (int)Double.MAX_VALUE; //ƂŋߎȐ\鎞̂߂ɍőlƍŏlĂB_ȉ͂ȂB
		int dataMax = 0;
		for(int i=0; i<dataList.size(); i++){ //ŃXgzɈڂւAȍ~͂̔z񂩂f[^QƂBdoublev~eBu^Ȃ̂ł傤ǂ\bhȂ炵
			data[i] = dataList.get(i);
			if (data[i] < dataMin) dataMin = (int)data[i];
			if (data[i] > dataMax) dataMax = (int)data[i];
		}
		int size = data.length;
		
		//kϖ@Ńf[^̏NX^
		int[] initCluster = kmeans(data, dataMin, dataMax, maxIter);
		
		//Explicitp[^̏
		double[] phi = new double[clusterMax];
		double[] mean = new double[clusterMax];
		double[] var = new double[clusterMax];
		for (int k=0; k<clusterMax; k++) {
			phi[k] = 0.0;
			mean[k] = 0.0;
			var[k] = 0.0;
		}
		int[] dataNum = new int[clusterMax];
		for(int i=0; i<size; i++){
			int index = initCluster[i];
			dataNum[index]++;
			phi[index]++;
			mean[index] += data[i];
		}
		for(int k=0; k<clusterMax; k++) {
			if(dataNum[k]==0) continue;
			phi[k] /= (double)size;
			mean[k] /= (double)dataNum[k];
		}
		for(int i=0; i<size; i++) {
			int index = initCluster[i];
			double gap = data[i] - mean[index];
			var[index] += gap*gap;
		}
		for(int k=0; k<clusterMax; k++) {
			var[k] /= (double)dataNum[k];
		}
		
		//Ce[^
		double[][] eAff =new double[size][clusterMax];
		double[] sqrtVar = new double[clusterMax];
		final double cnst = Math.sqrt(2.0*Math.PI);
		for(int itr=0; itr<maxIter; itr++){
			
			for(int k=0; k<clusterMax; k++){
				sqrtVar[k] = Math.sqrt(var[k]);
			}
			
			//EXebv
			double[] denom = new double[size];
			for(int i=0; i<size; i++){
				denom[i] = 0.0;
				for(int k=0; k<clusterMax; k++){
					double gap = data[i] - mean[k];
					eAff[i][k] = phi[k] * Math.exp(-0.5*gap*gap/var[k])/(cnst*sqrtVar[k]);
					denom[i] += eAff[i][k];
				}
				for(int k=0; k<clusterMax; k++){
					eAff[i][k] /= denom[i];
				}
			}
			
			//MXebv
			double[] sumAff = new double[clusterMax];
			for(int k=0; k<clusterMax; k++){
				phi[k] = 0.0;
				sumAff[k] = 0.0;
				mean[k] = 0.0;
				var[k] = 0.0;
				
				for(int i=0; i<size; i++){
					sumAff[k] += eAff[i][k];
					mean[k] += data[i]*eAff[i][k];
				}
				phi[k] = sumAff[k]/(double)size;
				mean[k] /= sumAff[k];
				
				for(int i=0; i<size; i++){
					double gap = data[i] - mean[k];
					var[k] += gap*gap*eAff[i][k];
				}
				
				var[k] /= sumAff[k];
			}
		}
		
		
		//ʏo
		OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(resFile));
		BufferedWriter bw = new BufferedWriter(osw);
		bw.write(head);
		bw.newLine();
		
		//ߎȐvbgEo
		int range = dataMax - dataMin;
		int pitch = 10;
		int resol = range/pitch;
		for (int r=0; r<resol; r++) {
			double plot = 0.0;
			double subPlot = 0.0;
			int time = dataMin + pitch*r;
			bw.write(String.format("%d", time));
			for (int k=0; k<clusterMax; k++) {
				subPlot = phi[k]*gaussian(time,mean[k],var[k]);
				bw.write(String.format(",%f", subPlot));
				plot += subPlot;
			}
			bw.write(String.format(",%f", plot));
			bw.newLine();
		}
		bw.newLine();
		
		//NX^o
		for(int k=0; k<clusterMax; k++) {
			bw.write(String.format("#Cluster No.%d", k));
			bw.newLine();
			bw.write(String.format("weight: %f", phi[k]));
			bw.newLine();
			bw.write(String.format("mean: %f", mean[k]));
			bw.newLine();
			bw.write(String.format("variance: %f", var[k]));
			bw.newLine();
			bw.newLine();
		}
		bw.close();
		osw.close();
		
		
	}