/// <summary>
        /// 四分位数を計算する。
        /// </summary>
        /// <param name="designMatrix"></param>
        /// <returns></returns>
        public static double[,] Lower_Quartile_Sample(double[,] designMatrix)
        {
            //配列を昇順に並べ替える。
            double[,] sorted = InferentialStatistics.Sorted_in_Ascending_Order(designMatrix);


            double[,] lowerQuartile = new double[1, sorted.GetLength(1)];

            //四分位数は、要素数を4で割ったときのあまりで計算が異なる。
            int lower_quartile_point = sorted.GetLength(0) / 4;

            if (sorted.GetLength(0) % 4 < 2)
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    lowerQuartile[0, j] = (sorted[lower_quartile_point, j] + sorted[Math.Max(lower_quartile_point - 1, 0), j]) / 2;
                }
            }
            else
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    lowerQuartile[0, j] = sorted[lower_quartile_point, j];
                }
            }

            return(lowerQuartile);
        }
        /// <summary>
        /// 中央値を計算する
        /// </summary>
        /// <param name="designMatrix"></param>
        /// <returns></returns>
        public static double[,] Median(double[,] designMatrix)
        {
            //配列を昇順に並べ替える。
            double[,] sorted = InferentialStatistics.Sorted_in_Ascending_Order(designMatrix);


            double[,] median = new double[1, sorted.GetLength(1)];

            //中央値は、要素数を2で割ったときのあまりで計算が異なる。
            int median_point = sorted.GetLength(0) / 2;

            if (sorted.GetLength(0) % 2 == 0)
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    median[0, j] = (sorted[median_point, j] + sorted[Math.Max(median_point - 1, 0), j]) / 2;
                }
            }
            else
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    median[0, j] = sorted[median_point, j];
                }
            }

            return(median);
        }
        /// <summary>
        /// 相関係数を計算する。
        /// </summary>
        /// <param name="designMatrix"></param>
        /// <returns></returns>
        public static double[,] Correlation_Matrix_Sample(double[,] designMatrix)
        {
            //分散共分散行列
            double[,] variance_Covariance_Matrix = InferentialStatistics.Variance_Covariance_Matrix_Nonbias(designMatrix);

            //標準偏差を計算する
            double[] std = new double[designMatrix.GetLength(1)];
            for (int j = 0; j < variance_Covariance_Matrix.GetLength(0); j++)
            {
                std[j] = Math.Sqrt(variance_Covariance_Matrix[j, j]);
            }

            //相関係数行列
            double[,] CorrelationMatrix
                = new double[designMatrix.GetLength(1), designMatrix.GetLength(1)];

            //相関係数を計算する。
            for (int i = 0; i < CorrelationMatrix.GetLength(0); i++)
            {
                for (int j = 0; j < CorrelationMatrix.GetLength(1); j++)
                {
                    CorrelationMatrix[i, j] = variance_Covariance_Matrix[i, j] / std[i] / std[j];
                }
            }

            return(CorrelationMatrix);
        }
        /// <summary>
        /// [0,*] 最小値
        /// [1,*] 第一四分位数
        /// [2,*] 中央値
        /// [3,*] 平均値
        /// [4,*] 第三四分位数
        /// [5,*] 最大値
        /// [6,*] 偏差平方和
        /// [7,*] 不偏分散
        /// [8,*] 不偏標準偏差
        /// </summary>
        /// <param name="design_Matrix"></param>
        /// <returns></returns>
        public static double[,] Summary(double[,] designMatrix)
        {
            //配列を昇順に並べ替える。
            double[,] sorted = InferentialStatistics.Sorted_in_Ascending_Order(designMatrix);


            double[,] summary = new double[9, sorted.GetLength(1)];


            //[0,*] 最小値 and [5,*] 最大値
            for (int j = 0; j < summary.GetLength(1); j++)
            {
                summary[0, j] = sorted[0, j];
                summary[5, j] = sorted[sorted.GetLength(0) - 1, j];
            }

            //[3,*] 平均値
            for (int j = 0; j < sorted.GetLength(1); j++)
            {
                for (int i = 0; i < sorted.GetLength(0); i++)
                {
                    summary[3, j] += sorted[i, j];
                }
                summary[3, j] /= sorted.GetLength(0);
            }

            //[2,*] 中央値
            int median_point = sorted.GetLength(0) / 2;

            if (sorted.GetLength(0) % 2 == 0)
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    summary[2, j] = (sorted[median_point, j] + sorted[Math.Max(median_point - 1, 0), j]) / 2;
                }
            }
            else
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    summary[2, j] = sorted[median_point, j];
                }
            }

            //[1,*] 第一四分位数
            //[4,*] 第三四分位数
            int lower_quartile_point = sorted.GetLength(0) / 4;
            int upper_quartile_point = Math.Max(sorted.GetLength(0) - sorted.GetLength(0) / 4, 0);

            if (sorted.GetLength(0) % 4 < 2)
            {
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    summary[1, j] = (sorted[lower_quartile_point, j] + sorted[Math.Max(lower_quartile_point - 1, 0), j]) / 2;
                    summary[4, j] = (sorted[upper_quartile_point, j] + sorted[Math.Max(upper_quartile_point - 1, 0), j]) / 2;
                }
            }
            else
            {
                upper_quartile_point = Math.Max(upper_quartile_point - 1, 0);
                for (int j = 0; j < sorted.GetLength(1); j++)
                {
                    summary[1, j] = sorted[lower_quartile_point, j];
                    summary[4, j] = sorted[upper_quartile_point, j];
                }
            }

            //[6,*] 偏差平方和
            for (int i = 0; i < designMatrix.GetLength(0); i++)
            {
                for (int j = 0; j < designMatrix.GetLength(1); j++)
                {
                    summary[6, j] += (designMatrix[i, j] - summary[3, j]) * (designMatrix[i, j] - summary[3, j]);
                }
            }

            //[7,*] 不偏分散
            //[8,*] 不偏標準偏差
            for (int j = 0; j < designMatrix.GetLength(1); j++)
            {
                summary[7, j] = summary[6, j] / (designMatrix.GetLength(0) - 1);
                summary[8, j] = Math.Sqrt(summary[7, j]);
            }


            return(summary);
        }