当前位置: 首页>>代码示例>>C#>>正文


C# BigNumber.GetLength方法代码示例

本文整理汇总了C#中BigNumber.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# BigNumber.GetLength方法的具体用法?C# BigNumber.GetLength怎么用?C# BigNumber.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigNumber的用法示例。


在下文中一共展示了BigNumber.GetLength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MatPlus

        public static BigNumber[,] MatPlus(BigNumber[,] mat1, BigNumber[,] mat2)
        {//矩阵加法
            int len11 = mat1.GetLength(0);
            int len12 = mat1.GetLength(1);
            int len21 = mat2.GetLength(0);
            int len22 = mat2.GetLength(1);

            if (len11 == len21 && len12 == len22)
            {
                BigNumber[,] a = new BigNumber[len11, len12];
                for (int i = 0; i < len11; i++)
                {
                    for (int j = 0; j < len12; j++)
                    {
                        a[i, j] = mat1[i, j] + mat2[i, j];
                    }
                }
                return a;
            }
            else
            {
                return null;
            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:24,代码来源:StringCount_and_list.cs

示例2: MatTrans

 public static BigNumber[,] MatTrans(BigNumber[,] mat)
 {
     //矩阵转置
     int len1 = mat.GetLength(0);
     int len2 = mat.GetLength(1);
     BigNumber[,] a = new BigNumber[len2, len1];
     for (int i = 0; i < len1; i++)
     {
         for (int j = 0; j < len2; j++)
         {
             a[j, i] = mat[i, j];
         }
     }
     return a;
 }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:15,代码来源:StringCount_and_list.cs

示例3: MatCorr

 public static BigNumber[,] MatCorr(BigNumber[,] matrix)
 {
     int len1 = matrix.GetLength(0);
     int len2 = matrix.GetLength(1);
     BigNumber[] a1 = new BigNumber[len1 * len2];
     for (int j = 0; j < len2; j++)
     {
         for (int i = 0; i < len1; i++)
         {
             a1[j * len1 + i] = matrix[i, j];
         }
     }
     BigNumber[] a2 = new BigNumber[len1];
     BigNumber[] a3 = new BigNumber[len1];
     BigNumber[,] corr = new BigNumber[len2, len2];
     for (int c = 1; c < len2 ;c++  )
     {
         for (int j = 0; j < len2 -1; j++)
         {
             for (int i = 0; i < len1; i++)
             {
                 a2[i] = a1[j * len1 + i];
             }
             for (int i = 0; i < len1; i++)
             {
                 a3[i] = a1[(j +1)* len1 + i];
             }
             try
             {
                 corr[j, j + c] = Corr(a2, a3);
                 corr[j + c, j] = Corr(a2, a3);
             }
             catch (Exception ex)
             {
                 
             }
       }
     }
     for (int i = 0; i < len2;i ++ )
     {
         corr[i, i] = new BigNumber("1");
     }
         return corr;
   }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:44,代码来源:MatCorr.cs

示例4: MatTimes

 public static BigNumber[,] MatTimes(BigNumber[,] mat1, BigNumber[,] mat2)
 {    //矩阵乘法
     int len11 = mat1.GetLength(0);
     int len12 = mat1.GetLength(1);
     int len21 = mat2.GetLength(0);
     int len22 = mat2.GetLength(1);
     if (len12 == len21)
     {
         BigNumber[,] a = new BigNumber[len11, len22];
         for (int i = 0; i < len11; i++)
         {
             for (int j = 0; j < len22; j++)
             {
                 for (int u = 0; u < len12; u++)
                 {
                     a[i, j] += mat1[i, u] * mat2[u, j];
                 }
             }
         }
         return a;
     }
     else
     {
         return null;
     }
 }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:26,代码来源:StringCount_and_list.cs

示例5: MutiRegR

    public static string MutiRegR(BigNumber[,] x, BigNumber[,] y)
    {    //返回多元回归拟合优度R^2 and adj_R^2
        int len11 = x.GetLength(0);//x行数
        int len12 = x.GetLength(1);//x列数
        int len21 = y.GetLength(1);//y列数
        int len22 = y.GetLength(0);//y列数
        if (len21 != 1)
        {
            return null;
        }
        BigNumber ysum = new BigNumber("0");
        for (int i = 0; i < len11;i++ )
        {
            ysum += y[i,1];
        }
        BigNumber ybar = ysum / (new BigNumber(len11.ToString()));
        BigNumber TSS = new BigNumber("0");
        for (int i = 0; i < len11; i++)
        {
            TSS += (y[i, 1] - ybar).Power(new BigNumber("2"));
        }
        BigNumber[,] b1 = MathV.MatTrans(x);
        BigNumber[,] b2 = MathV.MatTimes(b1, x);
        BigNumber[,] b3 = Stat.MatInv(b2, len12);
        BigNumber[,] b4 = MathV.MatTimes(b3, b1);
        BigNumber[,] bhat = MathV.MatTimes(b4, y);
        BigNumber[,] b5 = MathV.MatTimes(x, bhat);
        BigNumber[,] epsilon = MathV.MatMinu(y, b5);
        BigNumber ESS = new BigNumber("0");
        for (int i = 0; i < len11; i++)
        {
            ESS += (epsilon[i, 1]).Power(new BigNumber("2"));
        }
        BigNumber MSS = TSS - ESS;
        BigNumber Rsquare = MSS / TSS;
        BigNumber Adj_Rsquare = new BigNumber("1") - (new BigNumber("1")- Rsquare)*(new BigNumber(len11.ToString()) -new BigNumber("1") / (new BigNumber(len11.ToString()) -new BigNumber(len12.ToString()) -new BigNumber("1")));
        BigNumber Fvalue = (MSS/new BigNumber(len12.ToString()))/(ESS/( new BigNumber(len11.ToString())- new BigNumber(len12.ToString()) - new BigNumber("1") ));
        return Rsquare.ToString() + "," + Adj_Rsquare.ToString() + ","+ Fvalue.ToString();
 
    }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:40,代码来源:MatCorr.cs

示例6: MutiRegP

 public static BigNumber[] MutiRegP(BigNumber[,] x, BigNumber[,] y)
 {    //返回多元回归P值
     int len11 = x.GetLength(0);//行数
     int len12 = x.GetLength(1);//列数
     int len21 = y.GetLength(1);//y列数
     if (len21 != 1)
     {
         return null;
     }
     BigNumber[,] b1 = MathV.MatTrans(x);
     BigNumber[,] b2 = MathV.MatTimes(b1, x);
     BigNumber[,] b3 = Stat.MatInv(b2, len12);
     BigNumber[,] b4 = MathV.MatTimes(b3, b1);
     BigNumber[,] bhat = MathV.MatTimes(b4, y);
     BigNumber[,] b5 = MathV.MatTimes(x, bhat);
     BigNumber[,] epsilon = MathV.MatMinu(y, b5);
     BigNumber[] variance = new BigNumber[len12];
     for (int i = 1; i < len11; i++)
     {
         variance[i] = epsilon[i, 1];
     }
     BigNumber sigma2 = Variance(variance) * new BigNumber(((len11 - 1) / len11).ToString());
     BigNumber[,] b6 = new BigNumber[len12, len12]; //sigma^2*(C^T C)^{-1} 参数方差
     for (int i = 0; i < len12; i++)
     {
         for (int j = 0; j < len12; j++)
         {
             b6[i, j] = sigma2 * b3[i, j];
         }
     }
     BigNumber[] std_b = new BigNumber[len12];
     for (int i = 0; i < len12; i++)
     {
         std_b[i] = b6[i, i].Power(new BigNumber("0.5"));
     }
     BigNumber[] tvalue_b = new BigNumber[len12];
     for (int i = 0; i < len12; i++)
     {
         tvalue_b[i] = bhat[i, 1] / std_b[i];
     }
     BigNumber[] pvalue_b = new BigNumber[len12];
     for (int i = 0; i < len12; i++)
     {
         pvalue_b[i] = new BigNumber(Stat.NORMSDIST(Convert.ToDouble(tvalue_b[i].ToString())).ToString());
     }
     return pvalue_b;
      }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:47,代码来源:MatCorr.cs

示例7: BigNumber

       /* static void Main(string[] args)
       {
           BigNumber[,] dMatrix = new BigNumber[2, 2] { { new BigNumber("0"), new BigNumber("1") }, { new BigNumber("2"), new BigNumber("2") } };

           BigNumber[,] dReturn = MatInv(dMatrix,2);                              
           if (dReturn != null)  
             {
               for (int i = 0; i < 2; i++)
               Console.WriteLine(string.Format("{0} {1} ", dReturn[i, 0], dReturn[i, 1]));   //输出
               Console.ReadKey();
             }
        }*/

        public static BigNumber[,] MutiRegB(BigNumber[,] x,BigNumber[,] y)
        { //返回多元回归参数估计值**************************************注意:x第一列为1*******************
            int len11 = x.GetLength(0);//行数
            int len12 = x.GetLength(1);//列数
            BigNumber[,] b1 = MathV.MatTrans(x);
            BigNumber[,] b2 = MathV.MatTimes(b1, x);
            BigNumber[,] b3 = Stat.MatInv(b2, len12);
            BigNumber[,] b4 = MathV.MatTimes(b3,b1);
            BigNumber[,] bhat = MathV.MatTimes(b4, y);
            return bhat;
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:24,代码来源:MatCorr.cs

示例8: OneWayANOVA

        public static string OneWayANOVA(BigNumber[,] Numberseies)
        {   // 单因素方差分析
            int weidu = Numberseies.Rank;
            int x = Numberseies.GetLength(0);
            int y = Numberseies.GetLength(1);
            int z = Numberseies.Length;
            BigNumber SST = new BigNumber("0");
            BigNumber SSA = new BigNumber("0");
            BigNumber SSW = new BigNumber("0");
            BigNumber sum1 = new BigNumber("0");
            BigNumber[] sum2 = new BigNumber[y];
            for (int j = 0; j < y; j++)
            {
                for (int i = 0; i < x; i++)
                {
                    sum1 += Numberseies[i, j];
                    sum2[j] += Numberseies[i, j];
                }
            }
            BigNumber Txbar = sum1 / new BigNumber(z.ToString());
            BigNumber[] Axbar = new BigNumber[y];
            for (int j = 0; j < y; j++)
            {
                Axbar[j] = sum2[j] / new BigNumber(y.ToString());
            }

            for (int j = 0; j < y; j++)
            {
                SSA += new BigNumber(y.ToString()) * (Axbar[j] - Txbar).Power(new BigNumber("0.5"), 30);
            }

            for (int j = 0; j < y; j++)
            {
                for (int i = 0; i < x; i++)
                {
                    SST += (Numberseies[i, j] - Txbar).Power(new BigNumber("0.5"), 30);
                    SSW += (Numberseies[i, j] - Axbar[j]).Power(new BigNumber("0.5"), 30);
                }
            }
            BigNumber MSA = SSA / (new BigNumber(y.ToString()) - new BigNumber("1"));
            BigNumber MSW = SSW / (new BigNumber(z.ToString()) - new BigNumber(y.ToString()));
            BigNumber MST = SST / (new BigNumber(z.ToString()) - new BigNumber("1"));
            BigNumber Fvalue = MSA / MSW;
            return Fvalue.ToString();

        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:46,代码来源:MatCorr.cs

示例9: contingency

        public static string  contingency(BigNumber[,] table)
        {
            int len11 = table.GetLength(0);//x行数
            int len12 = table.GetLength(1);//x列数
            BigNumber[,] fe = new BigNumber[len11, len12];//给定单元中的频数期望值
            BigNumber chisq_value = new BigNumber("0");
            


            BigNumber sum = new BigNumber("0");
            BigNumber[] sum_c = new BigNumber[len12];
            BigNumber[] sum_r = new BigNumber[len11];
            

          for (int i = 0; i < len11; i++)
            {
                for (int j = 0; j < len12; j++)
                {

                    sum = sum + table[i, j];
                }
            }

            for (int j = 0; j < len12;j++ )
            {
                sum_c[j] = new BigNumber("0");
                for(int i =0; i<len11; i++)
                {
                    sum_c[j] += table[i,j];
                }
            }//对每一列求和
             for (int i = 0; i < len12; i++)
             {
                 sum_r[i] = new BigNumber("0");
                 for (int j = 0; j < len11; j++)
                 {
                     sum_r[i] += table[i, j];
                 }
             }//对每行求和

             for (int i = 0; i < len11;i++ )
             {       
                 for(int j = 0; j < len12;j++)
                 {
                     fe[i, j] = sum_r[i] * sum_c[j] / sum;
                        
                 }
             }//计算给定单元的频数期望值
            for (int i = 0; i < len11;i++ )
             {       
                 for(int j = 0; j < len12;j++)
                 {
            chisq_value = chisq_value+(table[i,j]-fe[i,j]).Power(new BigNumber("2"))/fe[i,j];

                 }
            }
            double Xsquare1;
            Xsquare1= Stat.chi2Ua(0.05, (len11-1)*(len12-1));//返回卡方分布临界值
            BigNumber Xsquare = new BigNumber(Xsquare1.ToString());

            if (CompareNumber.Compare(chisq_value, Xsquare) == 1 )
            {
                return "拒绝原假设,行列变量之间不独立";
            }
            else
            {
                return "不拒绝原假设,行列变量独立";
            }
        }
开发者ID:Cg87521,项目名称:stats,代码行数:69,代码来源:Xsquare_Independence_test.cs


注:本文中的BigNumber.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。