01 /*
02 * $Id: DataAnalysis.java,v 1.11 2008/02/02 03:06:26 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap20;
08
09 import java.io.IOException;
10
11 import org.mklab.nfc.matrix.DoubleMatrix;
12 import org.mklab.nfc.matrix.IntMatrix;
13 import org.mklab.nfc.matrix.Matrix;
14 import org.mklab.nfc.matx.MatxMatrix;
15
16
17 /**
18 * 与えられたデータ集合の平均値と標準偏差を求めるサンプルです。
19 * @author koga
20 * @version $Revision: 1.11 $, 2004/05/07
21 */
22 public class DataAnalysis {
23
24 /**
25 * メインメソッド
26 *
27 * @param args コマンドライン引数
28 * @throws IOException ファイルから読み込めない場合
29 */
30 @SuppressWarnings("nls")
31 public static void main(String[] args) throws IOException {
32 Matrix data = MatxMatrix.readMatFormat("data.mat");
33 Matrix grade = data.sumRowWise().multiply(5).addElementWise(60);
34 IntMatrix index = grade.compareElementWise(".>", 100).find();
35 grade.setSubVector(index, DoubleMatrix.ones(index).multiply(100));
36 grade = grade.roundElementWise();
37 System.out.println("平均点 = " + ((DoubleMatrix)grade).mean());
38 System.out.println("標準偏差 = " + ((DoubleMatrix)grade).std());
39 }
40 }
|