Пример #1
0
        public static void Example_2_3()
        {
            Basics_of_Statistical_Data_Analysis.Quote();

            Console.WriteLine("例題2.3を解きます。");
            Console.WriteLine("引用(は例題に関係するNo.1から16のみ記載)\n");
            Console.Write("表2.2のうち,No.1から16のデータについて,メジアン,第1四分位数点,第3四分位数点を求めなさい.");
            Console.Write("\n\n");

            double[,] design_Matrix = new double[16, 1];
            design_Matrix[0, 0]     = 565; design_Matrix[1, 0] = 685; design_Matrix[2, 0] = 714;
            design_Matrix[3, 0]     = 743; design_Matrix[4, 0] = 779; design_Matrix[5, 0] = 823;
            design_Matrix[6, 0]     = 824; design_Matrix[7, 0] = 945; design_Matrix[8, 0] = 967;

            design_Matrix[9, 0]  = 996; design_Matrix[10, 0] = 1056; design_Matrix[11, 0] = 1089;
            design_Matrix[12, 0] = 1102; design_Matrix[13, 0] = 1147; design_Matrix[14, 0] = 1152;
            design_Matrix[15, 0] = 1255;

            for (int j = 0; j < design_Matrix.GetLength(0); j++)
            {
                for (int k = 0; k < design_Matrix.GetLength(1); k++)
                {
                    Console.Write(design_Matrix[j, k] + "\t");
                }
                Console.WriteLine("");
            }


            Console.WriteLine("\n\n引用終わり\n");


            double[,] summary = Statistics.Summary(design_Matrix);

            Console.Write("[1,*] 第一四分位数\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[1, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[2,*] 中央値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[2, k] + "\t");
            }
            Console.WriteLine("");


            Console.Write("[4,*] 第三四分位数\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[4, k] + "\t");
            }
            Console.WriteLine("");
        }
Пример #2
0
        public static void Example_2_1()
        {
            Basics_of_Statistical_Data_Analysis.Quote();

            Console.WriteLine("例題2.1を解きます。");
            Console.WriteLine("引用(数式は改変)\n");
            Console.Write("下記は,2015年度の都道府県別栽培きのこ類生産量(単位千円)である。");
            Console.Write("このデータについて、平均x_average,メジアンx_medianを計算しなさい。\n");

            string[,] Label = new string[7, 1];
            Label[0, 0]     = "大阪\t";
            Label[1, 0]     = "佐賀\t";
            Label[2, 0]     = "山口\t";
            Label[3, 0]     = "東京\t";
            Label[4, 0]     = "山梨\t";
            Label[5, 0]     = "神奈川\t";
            Label[6, 0]     = "長野\t";
            for (int j = 0; j < Label.GetLength(0); j++)
            {
                Console.Write(Label[j, 0] + "\t");
            }
            Console.Write("\n");

            double[,] design_Matrix = new double[7, 1];
            design_Matrix[0, 0]     = 14;
            design_Matrix[1, 0]     = 21;
            design_Matrix[2, 0]     = 22;
            design_Matrix[3, 0]     = 23;
            design_Matrix[4, 0]     = 25;
            design_Matrix[5, 0]     = 39;
            design_Matrix[6, 0]     = 4955;
            for (int j = 0; j < design_Matrix.GetLength(0); j++)
            {
                Console.Write(design_Matrix[j, 0] + "\t\t");
            }
            Console.Write("\n");

            Console.WriteLine("\n引用終わり(数式は改変)\n");

            double[,] summary = Statistics.Summary(design_Matrix);
            Console.WriteLine("[0,*] 最小値\t\t" + summary[0, 0]);
            Console.WriteLine("[1,*] 第一四分位数\t" + summary[1, 0]);
            Console.WriteLine("[2,*] 中央値\t\t" + summary[2, 0]);
            Console.WriteLine("[3,*] 平均値\t\t" + summary[3, 0]);
            Console.WriteLine("[4,*] 第三四分位数\t" + summary[4, 0]);
            Console.WriteLine("[5,*] 最大値\t\t" + summary[5, 0]);
        }
Пример #3
0
        public static void Example_2_2()
        {
            Basics_of_Statistical_Data_Analysis.Quote();

            Console.WriteLine("例題2.2を解きます。");
            Console.WriteLine("引用(数式は改変)\n");
            Console.Write("次のデータ(a)について,平均x_average,メジアンx_median,偏差平方和S,分散s^2,標準偏差sを計算しなさい。");
            Console.Write("次にデータ(b)から(d)のそれぞれについて,x_average,x_median,S,s^2,sを求めなさい。");
            Console.Write("その際、(b)のデータは(a)のデータに100を加えている。");
            Console.Write("(c)のデータは平均からの偏差が倍であるなどの特徴に着目して計算しなさい。\n\n");

            double[,] design_Matrix = new double[9, 4];
            design_Matrix[0, 0]     = 53; design_Matrix[1, 0] = 55; design_Matrix[2, 0] = 52;
            design_Matrix[3, 0]     = 57; design_Matrix[4, 0] = 51; design_Matrix[5, 0] = 56;
            design_Matrix[6, 0]     = 58; design_Matrix[7, 0] = 59; design_Matrix[8, 0] = 54;

            design_Matrix[0, 1] = 153; design_Matrix[1, 1] = 155; design_Matrix[2, 1] = 152;
            design_Matrix[3, 1] = 157; design_Matrix[4, 1] = 151; design_Matrix[5, 1] = 156;
            design_Matrix[6, 1] = 158; design_Matrix[7, 1] = 159; design_Matrix[8, 1] = 154;

            design_Matrix[0, 2] = 51; design_Matrix[1, 2] = 55; design_Matrix[2, 2] = 49;
            design_Matrix[3, 2] = 59; design_Matrix[4, 2] = 47; design_Matrix[5, 2] = 57;
            design_Matrix[6, 2] = 61; design_Matrix[7, 2] = 63; design_Matrix[8, 2] = 53;

            design_Matrix[0, 3] = 53; design_Matrix[1, 3] = 55; design_Matrix[2, 3] = 52;
            design_Matrix[3, 3] = 57; design_Matrix[4, 3] = 51; design_Matrix[5, 3] = 56;
            design_Matrix[6, 3] = 58; design_Matrix[7, 3] = 149; design_Matrix[8, 3] = 54;


            Console.WriteLine("(a)\t(b)\t(c)\t(d)");
            for (int j = 0; j < design_Matrix.GetLength(0); j++)
            {
                for (int k = 0; k < design_Matrix.GetLength(1); k++)
                {
                    Console.Write(design_Matrix[j, k] + "\t");
                }
                Console.WriteLine("");
            }


            Console.WriteLine("\n\n引用終わり(数式は改変)\n");


            double[,] summary = Statistics.Summary(design_Matrix);
            Console.Write("[0,*] 最小値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[0, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[1,*] 第一四分位数\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[1, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[2,*] 中央値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[2, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[3,*] 平均値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[3, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[4,*] 第三四分位数\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[4, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[5,*] 最大値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[5, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[6,*] 偏差平方和\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[6, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[7,*] 標本分散\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[7, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[8,*] 標本標準偏差\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[8, k].ToString("G3") + "\t");
            }
            Console.WriteLine("");
        }
        public static void Exercise_2_1()
        {
            Basics_of_Statistical_Data_Analysis.Quote();

            Console.Write("第2章 単一変数データの記述統計量と視覚的表現");
            Console.WriteLine("演習問題1を解きます。");
            Console.WriteLine("引用(数式は改変)\n");

            Console.Write("本問は,データ変換後に統計量を計算すると,計算が容易になる例を示している.");
            Console.Write("5人の高校生の50m走のタイムx1 , ・・・ , x5 (秒) を6.7 , 6.1 , 7.5 , 7.1 , 6.3 とする.\n\n");

            double[,] design_Matrix_x = new double[5, 1];
            design_Matrix_x[0, 0]     = 6.7; design_Matrix_x[1, 0] = 6.1; design_Matrix_x[2, 0] = 7.5;
            design_Matrix_x[3, 0]     = 7.1; design_Matrix_x[4, 0] = 6.3;

            Console.WriteLine("(a) 5人の高タイムから6を引いて10倍した数値y1 , ・・・ , y5を求めなさい。");
            double[,] design_Matrix_y = new double[5, 1];
            for (int j = 0; j < design_Matrix_x.GetLength(0); j++)
            {
                design_Matrix_y[j, 0] = Math.Round(10 * (design_Matrix_x[j, 0] - 6));
                Console.WriteLine("y" + (j + 1) + "\t" + design_Matrix_y[j, 0]);
            }
            Console.WriteLine("");

            Console.WriteLine("(b) 上記の5つの数値について,平均,平方和,分散,標準偏差を求めなさい.");
            double[,] summary = Statistics.Summary(design_Matrix_y);

            Console.Write("[3,*] 平均値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[3, k] + "\t");
            }
            Console.WriteLine("");

            Console.Write("[6,*] 偏差平方和\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[6, k].ToString("G3") + "\t");
            }
            Console.WriteLine("");

            Console.Write("[7,*] 標本分散\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[7, k].ToString("G3") + "\t");
            }
            Console.WriteLine("");

            Console.Write("[8,*] 標本標準偏差\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[8, k].ToString("G3") + "\t");
            }
            Console.WriteLine("");
            Console.WriteLine("");

            Console.WriteLine("(c) 上記の結果を利用して,この5人の50m走のタイムの平均,平方和,分散,標準偏差を求めなさい.");
            Console.WriteLine("y = 10 ( x - 6 )=10x -60");
            Console.WriteLine("x = y/10 + 6");
            Console.WriteLine("");

            Console.WriteLine("したがって、 E[x] = E[y/10 + 6] = E[y]/10 + 6");
            Console.Write("[3,*] 平均値\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write(summary[3, k] / 10 + 6 + "\t");
            }
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("同様に、 S[x] = S[y/10 + 6] = S[y/10] = S[y]/10^2");
            Console.Write("[6,*] 偏差平方和\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write((summary[6, k] / 100).ToString("G3") + "\t");
            }
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("s2[x] = s2[y/10 + 6] = s2[y/10] = s2[y]/10^2");
            Console.Write("[7,*] 標本分散\t\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write((summary[7, k] / 100).ToString("G3") + "\t");
            }
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("s[x] = s[y/10 + 6] = s[y/10] = s[y]/10");
            Console.Write("[8,*] 標本標準偏差\t");
            for (int k = 0; k < summary.GetLength(1); k++)
            {
                Console.Write((summary[8, k] / 10).ToString("G3") + "\t");
            }
            Console.WriteLine("");
        }