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


C# BigNumber.ToString方法代码示例

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


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

示例1: Regression

       public static string Regression(BigNumber[] x,BigNumber[] y,int n)
        {
            BigNumber sumx = new BigNumber("0");
            BigNumber sumy = new BigNumber("0");
            BigNumber lxy = new BigNumber("0");
            BigNumber lxx = new BigNumber("0");
            BigNumber xbar, ybar, beta0, beta1;

            for (int i = 0; i < n; i++)
            {
                sumx = sumx + x[i];
            }

            xbar = sumx / new BigNumber(x.Length.ToString());
            for (int a = 0; a <= n-1; a++)
            {
                lxx = lxx + (x[a] - xbar).Power(new BigNumber("2"));
            }
            for (int i = 0; i <= n-1; i++)
            {
                sumy = sumy + y[i];
            }
            ybar = sumy / new BigNumber(y.Length.ToString());
            for (int i = 0; i <= n-1; i++)
            {
                lxy = lxy + (x[i] - xbar) * (y[i] - ybar);
            }
            beta1 = lxy / lxx;
            beta0 = ybar - beta1 * xbar;
          
            BigNumber[] Ey = new BigNumber[n];
            BigNumber[] residual = new BigNumber[n];
            BigNumber SSR = new BigNumber("0");
            BigNumber SSE = new BigNumber("0");
            BigNumber Fvalue, Rsquare;
            for (int i =0;i <= n-1; i++)
            {
                Ey[i] = beta0 + beta1 * x[i];
            }
            for (int i=0; i <= n-1;i++)
            {
                residual[i] = y[i] - Ey[i];
            }
            for (int i = 0; i <= n - 1; i++)
            {
                SSR = SSR + (Ey[i] - ybar).Power(new BigNumber("2"));
                SSE = SSE + (y[i] - Ey[i]).Power(new BigNumber("2"));
            }
            Fvalue = SSR / SSE * (new BigNumber( n.ToString()) - new BigNumber("2"));
            string f = Fvalue.ToString();
            double F =  Convert.ToDouble(f);
            Rsquare = SSR / (SSR+SSE);
           // BigNumber Fa = new BigNumber(Stat.FdistUa(0.05, 2,1).ToString());
            //BigNumber FF =new BigNumber("1") / Fa;
            BigNumber p = new BigNumber(Stat.FCDF(F, 1, 2).ToString());
            return p.ToString()+" "+f;//+" "+ Fvalue.ToString();//"回归方程为:y=" + MathV.round(beta0.ToString(),3,0)+ "+" + MathV.round(beta1.ToString(),3,0) + "*x"+" Rsquare:"+MathV.round(Rsquare.ToString(),3,0)+" Fvalue:"+MathV.round(Fvalue.ToString(),3,0);
        }
开发者ID:Cg87521,项目名称:stats,代码行数:57,代码来源:onevariable_regression.cs

示例2: Proportion

     static BigNumber Proportion(BigNumber[] NumberSeries,BigNumber goalnumber)
     {      int n = NumberSeries.Length;
            BigNumber count= new BigNumber("0");
            BigNumber goal= new BigNumber(goalnumber.ToString());
            for (int i = 0; i< n; i++ )
            {
                if (CompareNumber.Compare(NumberSeries[i],goal) == 0)
                {
                    count = count + new BigNumber("1");
                  }
                else
             {
                 count = count + new BigNumber("0");
             }
            }
            return count / new BigNumber(n.ToString());

        }//计算目标样本比例p
开发者ID:Cg87521,项目名称:stats,代码行数:18,代码来源:ztest_proportion.cs

示例3: round

        static string round(string number, int digits)
        {
            int NumOriginLen = number.Length;
            char[] digit_dot = { '.' };
            string[] NumberBroken;
            NumberBroken = number.Split(digit_dot);
            if (digits < 0)
            {
                digits = 0;
            }
            if (NumberBroken[0].Length == NumOriginLen)
            {
                return NumberBroken[0] + ".".PadRight(digits + 1, '0');
            }
            else
            {
                string decimal_part = " ";
                BigNumber zero_point_one = new BigNumber("0.1");
                BigNumber one = new BigNumber("1");
                if (NumberBroken[1].Length > digits)
                {
                    if (Convert.ToInt32(NumberBroken[1].Substring(digits, 1)) > 4)
                    {
                        BigNumber carry = new BigNumber(digits.ToString());
                        carry = zero_point_one.Power(carry, 200);
                        BigNumber number_changed = new BigNumber(number);
                        number_changed = number_changed + carry;
                        return number_changed.ToString().Substring(0, NumOriginLen - (NumberBroken[1].Length - digits));
                    }
                    else
                    {
                        decimal_part = NumberBroken[1].Substring(0, digits);
                    }

                }
                else
                {
                    decimal_part = NumberBroken[1].PadRight(digits, '0');
                }
                return NumberBroken[0] + '.' + decimal_part;
            }
        }
开发者ID:JoshuaHe2015,项目名称:VISAP_Basic,代码行数:42,代码来源:MeanAndSort.cs

示例4: HT1

 //HT = Hypothesis Testing
 //假设检验,返回string
 //HT1为单样本检验
 //Tail = "less"为左单尾检验,Tail = "greater"为右单尾。Tail = "two" 为双尾检验
 //对于无需使用的值赋为-1即可,比如均值检验时无需使用比例,则赋值为-1。
 //type = "Mean.Test"为均值检验
 //type = "Proportion.Test"为比例检验
 //返回为字符串,如: 3.5,7.6  以逗号分隔
 //如果没有输入正确的type则返回NA
 public static string HT1(BigNumber H0, BigNumber Mean, BigNumber Variance, BigNumber Proportion,BigNumber len, double Significance, string Tail, string type)
 {
     Tail = Tail.ToLower();
     if (type == "Mean.Test")
     {
         //均值检验
         BigNumber tvalue = (H0 - Mean) / ((Variance / len).Power(new BigNumber("0.5"), 10));
         Double t_value = Convert.ToDouble(tvalue.ToString());
         BigNumber pvalue = new BigNumber((MathV.round(NORMSDIST(t_value).ToString(),7,0)).ToString());//取前十位
         string result = CI1(Mean,Variance,Proportion,len,Significance,Tail,type);
         char[] separator = { ',' };
         string[] intervals = result.Split(separator);
         if (Tail == "two")
         {
             BigNumber lower = new BigNumber(intervals[0]);
             BigNumber upper = new BigNumber(intervals[1]);
             if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
             {
                 return tvalue.ToString()+ "," + pvalue.ToString() + "," + "不拒绝原假设";
             }
             else
             {
                 return tvalue.ToString() + "," + pvalue.ToString() + "," + "拒绝原假设";
             }
         }
         else
         {
             if (Tail == "greater")
             {
                 BigNumber lower = new BigNumber(intervals[0]);
                 if (CompareNumber.Compare(lower, H0) == -1)
                 {
                     return tvalue.ToString() + "," + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                 }
                 else
                 {
                     return tvalue.ToString() + "," + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                 }
             }
             else
             {
                 if (Tail == "less")
                 {
                     BigNumber upper = new BigNumber(intervals[1]);
                     if (CompareNumber.Compare(upper, H0) == 1)
                     {
                         return tvalue.ToString() + "," + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                     }
                     else
                     {
                         return tvalue.ToString() + "," + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                     }
                 }
                 else
                 {
                     return "null";
                 }
             }
         }
     }
     else if (type == "Proportion.Test")
     {
         //比例检验
         string result = CI1(Mean, Variance, Proportion, len, Significance, Tail, type);
         char[] separator = { ',' };
         string[] intervals = result.Split(separator);
         BigNumber tvalue = (Proportion - H0) / ((H0 * (new BigNumber("1") - H0) / len).Power(new BigNumber("0.5"), 10));
         Double t_value = Convert.ToDouble(tvalue.ToString());
         BigNumber pvalue = new BigNumber((MathV.round(NORMSDIST(t_value).ToString(), 7, 0)).ToString());
         if (Tail == "two")
         {
             BigNumber lower = new BigNumber(intervals[0]);
             BigNumber upper = new BigNumber(intervals[1]);
             if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
             {
                 return tvalue.ToString() + "," + pvalue.ToString() + "," + "不拒绝原假设";
             }
             else
             {
                 return tvalue.ToString() + "," + pvalue.ToString() + "," + "拒绝原假设";
             }
         }
         else
         {
             if (Tail == "greater")
             {
                 BigNumber lower = new BigNumber(intervals[0]);
                 if (CompareNumber.Compare(lower, H0) == -1)
                 {
                     return tvalue.ToString() + "," + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                 }
//.........这里部分代码省略.........
开发者ID:Yangruipis,项目名称:Genesis,代码行数:101,代码来源:MatCorr.cs

示例5: Mode

        //仅限于寻找有序数列中的众数
        //多个众数时返回最小的众数
        public static string Mode(BigNumber[] NumberSeries)
        {

            double MaxCount = 0;
            double CurrentCount = 0;
            BigNumber MaxNumber = new BigNumber("0");
            BigNumber CurrentNumber = new BigNumber("0");
            int len = NumberSeries.Length;
            for (int i = 1; i < len; i++)
            {
                if (CompareNumber.Compare(NumberSeries[i - 1], NumberSeries[i]) == 0)
                {
                    CurrentCount++;
                    if (CurrentCount > MaxCount)
                    {
                        MaxCount = CurrentCount;
                        MaxNumber = NumberSeries[i];
                    }
                }
                else
                {
                    CurrentCount = 0;
                }
            }
            if (MaxCount == 0)
            {
                return "NA";
            }
            else
            {
                return MaxNumber.ToString();
            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:35,代码来源:MatCorr.cs

示例6: CI2

 //CI = Confidence Interval
 //置信区间的计算,返回string
 //CI2为双样本估计
 //len1,len2为两样本长度
 //Tail = "less"为左单尾估计,Tail = "greater"为右单尾。Tail = "two" 为双尾估计
 //对于无需使用的值赋为-1即可,比如均值估计时无需使用比例,则赋值为-1。
 //type = "Mean.Esti"为均值估计
 //type = "Proportion.Esti"为比例估计
 //type = "Variance.Esti"为方差比估计
 //返回为字符串,如: 3.5,7.6  以逗号分隔
 //如果没有输入正确的type则返回NA
 public static string CI2(BigNumber Mean1, BigNumber Mean2, BigNumber Variance1, BigNumber Variance2, BigNumber Proportion1, BigNumber Proportion2,BigNumber len1,BigNumber len2, double Significance, string Tail, string type)
 {
     BigNumber one = new BigNumber("1");
     BigNumber S_p = ((len1 - one) * Variance1 + (len2 - one) * Variance2) / (len1 + len2 - one - one);
     Tail = Tail.ToLower();
     if (type == "Mean.Esti")
     {   //均值估计
         if(Tail == "two"){
             Significance = Significance / 2;
             BigNumber lower = Mean1 - Mean2 - new BigNumber(NORMSINV(Significance).ToString()) * (S_p * (one / len1 + one / len2)).Power(new BigNumber("0.5"), 30);
             BigNumber upper = Mean1 - Mean2 + new BigNumber(NORMSINV(Significance).ToString()) * (S_p * (one / len1 + one / len2)).Power(new BigNumber("0.5"), 30);
             return lower.ToString() + "," + upper.ToString();
         }
         else
         {
             if(Tail == "greater"){
                 Significance = Significance / 1;
                 BigNumber lower = Mean1 - Mean2 - new BigNumber(NORMSINV(Significance).ToString()) * (S_p * (one / len1 + one / len2)).Power(new BigNumber("0.5"), 30);
                 return lower.ToString() + ",";
             }
             else
             {
                 if(Tail == "less"){
                     Significance = Significance / 1;
                     BigNumber upper = Mean1 - Mean2 + new BigNumber(NORMSINV(Significance).ToString()) * (S_p * (one / len1 + one / len2)).Power(new BigNumber("0.5"), 30);
                     return  "," + upper.ToString();
                 }
                 else
                 {
                     return "NA";
                 }
             }
         }
      
     }
     else if (type == "Proportion.Esti")
     {
         //比例估计
         if (Tail == "two")
         {
             Significance = Significance / 2;
             BigNumber lower = Proportion1 - Proportion2 - new BigNumber(NORMSINV(Significance).ToString()) * (Proportion1 * ((new BigNumber("1") - Proportion1) / len1 + Proportion2 * (new BigNumber("1") - Proportion2) / len2)).Power(new BigNumber("0.5"));
             BigNumber upper = Proportion1 - Proportion2 + new BigNumber(NORMSINV(Significance).ToString()) * (Proportion1 * ((new BigNumber("1") - Proportion1) / len1 + Proportion2 * (new BigNumber("1") - Proportion2) / len2)).Power(new BigNumber("0.5"));
             return lower.ToString() + "," + upper.ToString();
         }
         else
         {
             if(Tail == "greater"){
                 Significance = Significance / 1;
                 BigNumber lower = Proportion1 - Proportion2 - new BigNumber(NORMSINV(Significance).ToString()) * (Proportion1 * ((new BigNumber("1") - Proportion1) / len1 + Proportion2 * (new BigNumber("1") - Proportion2) / len2)).Power(new BigNumber("0.5"));
                 return lower.ToString() + ",";
             }
             else
             {
                 if (Tail == "less")
                 {
                 Significance = Significance / 1;
                 BigNumber upper = Proportion1 - Proportion2 + new BigNumber(NORMSINV(Significance).ToString()) * (Proportion1 * ((new BigNumber("1") - Proportion1) / len1 + Proportion2 * (new BigNumber("1") - Proportion2) / len2)).Power(new BigNumber("0.5"));
                 return "," + upper.ToString();
                  }
                 else
                 {
                     return "NA";
                 }
             }
         }
      
     }
     else if (type == "Variance.Esti")
     {
         //方差估计
         if (Tail == "two")
         {
             Significance =Significance /2;
             BigNumber lower = (Variance1 / Variance2) / new BigNumber(FCDF(Significance, Convert.ToInt32(len1.ToString()) - 1, Convert.ToInt32(len2.ToString()) - 1).ToString());
             BigNumber upper = (Variance1 / Variance2) * new BigNumber(FCDF(Significance, Convert.ToInt32(len2.ToString()) - 1, Convert.ToInt32(len1.ToString()) - 1).ToString());
             return lower.ToString() + "," + upper.ToString();
         }
         else
         {
             if (Tail == "greater")
             {
                 Significance = Significance / 1;
                 BigNumber lower = (Variance1 / Variance2) / new BigNumber(FCDF(Significance, Convert.ToInt32(len1.ToString()) - 1, Convert.ToInt32(len2.ToString()) - 1).ToString());
                 return lower.ToString() + ",";
             }
             else
             {
                 if (Tail == "less")
//.........这里部分代码省略.........
开发者ID:Yangruipis,项目名称:Genesis,代码行数:101,代码来源:MatCorr.cs

示例7: CI1

 //CI = Confidence Interval
 //置信区间的计算,返回string
 //CI1为单样本估计
 //len 为样本数
 //Tail = "less"为左单尾检验,Tail = "greater"为右单尾。Tail = "two" 为双尾检验
 //对于无需使用的值赋为-1即可,比如均值估计时无需使用比例,则赋值为-1。
 //type = "Mean.Esti"为均值估计
 //type = "Proportion.Esti"为比例估计
 //返回为字符串,如: 3.5,7.6  以逗号分隔
 //如果没有输入正确的type则返回NA
 public static string CI1(BigNumber Mean, BigNumber Variance, BigNumber Proportion,BigNumber len, double Significance, string Tail, string type)
 {
     Tail = Tail.ToLower();
     if (type == "Mean.Esti")
     {
         //均值估计
         BigNumber std = Variance.Power(new BigNumber("0.5"), 30);
         if (Tail == "two") { 
         Significance = Significance / 2;
         BigNumber lower = Mean - new BigNumber(NORMSINV(Significance).ToString()) * std / len.Power(new BigNumber("0.5"), 30);
         BigNumber upper = Mean + new BigNumber(NORMSINV(Significance).ToString()) * std / len.Power(new BigNumber("0.5"), 30);
         return lower.ToString()+ ","+upper.ToString();
         }
         else
         {
             if (Tail == "greater") //H0:mu>0
             {
                 Significance = Significance / 1;
                 BigNumber lower = Mean - new BigNumber(NORMSINV(Significance).ToString()) * std / len.Power(new BigNumber("0.5"), 30);
                 return lower.ToString() + ",";
             }
             else
             {
                 if (Tail == "less") //H0:mu>0
                 {
                     Significance = Significance / 1;
                     BigNumber upper = Mean + new BigNumber(NORMSINV(Significance).ToString()) * std / len.Power(new BigNumber("0.5"), 30);
                     return "," + upper.ToString();
                 }
                 else
                 {
                     return "NA";
                 }
             }
             
         }
         
       }
    
     else if (type == "Proportion.Esti")
     {
         BigNumber std = Variance.Power(new BigNumber("0.5"), 30);
         if (Tail == "two")
         {
             Significance = Significance / 2;
             BigNumber lower = Proportion - new BigNumber(NORMSINV(Significance).ToString()) * ((Proportion * (new BigNumber("1") - Proportion)) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
             BigNumber upper = Proportion + new BigNumber(NORMSINV(Significance).ToString()) * (Proportion * (new BigNumber("1") - Proportion) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
             return lower.ToString() + "," + upper.ToString();
         }
         else
         {
             if (Tail == "greater") //H0:mu>0
             {
                 Significance = Significance / 1;
                 BigNumber lower = Proportion - new BigNumber(NORMSINV(Significance).ToString()) * ((Proportion * (new BigNumber("1") - Proportion)) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                 return lower.ToString() + ",";
             }
             else
             {
                 if (Tail == "less") //H0:mu>0
                 {
                     Significance = Significance / 1;
                     BigNumber upper = Proportion + new BigNumber(NORMSINV(Significance).ToString()) * ((Proportion * (new BigNumber("1") - Proportion)) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                     return "," + upper.ToString();
                 }
                 else
                 {
                     return "NA";
                 }
             }
             
         }
         
     }
     else
     {
         return "NA";
     }
 }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:89,代码来源:MatCorr.cs

示例8: 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

示例9: HT1

        static string HT1(BigNumber H0, BigNumber len ,BigNumber mean ,BigNumber variance,BigNumber proportion, double significance, int tail)
        {
            BigNumber sd_series = variance.Power(new BigNumber("0.5"), 30);
            if ( CompareNumber.Compare(proportion,new BigNumber("0")) == 0 )
            {
            BigNumber tvalue = (H0-mean)/((variance/len).Power(new BigNumber("0.5"),10));
            Double t_value = Convert.ToDouble(tvalue.ToString());
            BigNumber pvalue = new BigNumber(NORMSDIST(t_value).ToString());

            if(tail == 2){
    
                significance = significance / 2;
                BigNumber lower = mean - new BigNumber(NORMSINV(significance).ToString()) * sd_series / len.Power(new BigNumber("-0.5"), 30);
                BigNumber upper = mean + new BigNumber(NORMSINV(significance).ToString()) * sd_series / len.Power(new BigNumber("-0.5"), 30);
                return "["+ lower.ToString() + "," +upper.ToString() +"]";
                if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
                {
                    return "t ="+ tvalue.ToString() +",P = " + pvalue.ToString() + "," + "不拒绝原假设";
                }
                else
                {
                    return "t =" + tvalue.ToString() + ",P = " + pvalue.ToString() + "," + "拒绝原假设";
                }
            }
            else
            {
                significance = significance / 1;
                BigNumber lower = mean - new BigNumber(NORMSINV(significance).ToString()) * sd_series / (len.Power(new BigNumber("-0.5"), 30));
                if (tail == 1)
                {
                    return "["+ lower.ToString() + ",]";
                    if (CompareNumber.Compare(lower, H0) == -1)
                    {
                        return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                        if(tail == -1)
                    {
                        return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                        else{
                            return "请输入正确的值";
                        }
                }
                else
                {
                    BigNumber upper = mean + new BigNumber(NORMSINV(significance).ToString()) * sd_series / (len.Power(new BigNumber("-0.5"), 30));
                    return "[," + upper.ToString()+ "]";
                    if (CompareNumber.Compare(upper, H0) == 1)
                    {
                        return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                }
            }
            }   
            else{
                BigNumber tvalue = (proportion - H0) / ((H0 * (new BigNumber("1") - H0) / len).Power(new BigNumber("0.5"), 10));
                Double t_value = Convert.ToDouble(tvalue.ToString());
                BigNumber pvalue = new BigNumber(NORMSDIST(t_value).ToString());
            if (tail == 2)
                {
                    significance = significance / 2;
                    BigNumber lower = proportion - new BigNumber(NORMSINV(significance).ToString()) * ((proportion * (new BigNumber("1") - proportion)) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                    BigNumber upper = proportion + new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                    return "["+lower.ToString() + "," + upper.ToString()+"]";
                    if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
                    {
                        return "t =" + tvalue.ToString() + ",P = " + pvalue.ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "t =" + tvalue.ToString() + ",P = " + pvalue.ToString() + "," + "拒绝原假设";
                    }
                }
                else
                {
                    significance = significance / 1;
                    if (tail == 1)
                    {

                        BigNumber lower = proportion - new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString())).Power(new BigNumber("0.5")));
                        return "["+lower.ToString() + ",]";
                        if (CompareNumber.Compare(lower, H0) == -1)
                        {
                            return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                        }
                        else
                        {
                            return "t =" + tvalue.ToString() + ",P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                        }
                    }
                    else{
                        if(tail == -1)
                       {
                        BigNumber upper = proportion + new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString())).Power(new BigNumber("0.5")));
                        return "["+"," + upper.ToString()+ "]";
//.........这里部分代码省略.........
开发者ID:Yangruipis,项目名称:Genesis,代码行数:101,代码来源:假设检验2.cs

示例10: ProportionHT

        static string ProportionHT(BigNumber H0, BigNumber[] NumberSeries,BigNumber charater, double significance, int tail)
        {
            //样本比例假设检验
            string result = ProportionEasti(NumberSeries,charater, significance, tail);
            char[] separator = { ',' };
            string[] intervals = result.Split(separator);
            BigNumber count = new BigNumber("0");
            int len = NumberSeries.Length;
            for (int i = 0; i < len; i++)
            {
                if (CompareNumber.Compare(NumberSeries[i], charater) == 0)
                {
                    count = count + new BigNumber("1");

                }
                else
                {
                    count = count + new BigNumber("0");
                }
            }
            BigNumber proportion = count / new BigNumber(len.ToString());
            BigNumber var_series = Variance(NumberSeries);
            BigNumber n = new BigNumber(NumberSeries.Length.ToString());
            BigNumber tvalue = (proportion - H0) / ((H0 * (new BigNumber("1") - H0) / n).Power(new BigNumber("0.5"), 10));
            Double t_value = Convert.ToDouble(tvalue.ToString());
            BigNumber pvalue = new BigNumber(NORMSDIST(t_value).ToString());
            //tail == 1右单尾,H0:x>= x_0,tail == -1 左单尾H0:x<= x_0,,为2则双尾
            if (tail == 2)
            {
                BigNumber lower = new BigNumber(intervals[0]);
                BigNumber upper = new BigNumber(intervals[1]);
                if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
                {
                    return "P = " + pvalue.ToString() + "," + "不拒绝原假设";
                }
                else
                {
                    return "P = " + pvalue.ToString() + "," + "拒绝原假设";
                }
            }
            else
            {
                if (tail == 1)
                {
                    BigNumber lower = new BigNumber(intervals[0]);
                    if (CompareNumber.Compare(lower, H0) == -1)
                    {
                        return "P = " + (new BigNumber("2") * pvalue- new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                }
                else
                {
                    BigNumber lower = new BigNumber(intervals[1]);
                    if (CompareNumber.Compare(lower, H0) == 1)
                    {
                        return "P = "+ (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                }
            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:68,代码来源:proportion+two+sample+(2).cs

示例11: ProportionEasti

        static string ProportionEasti(BigNumber[] NumberSeries, BigNumber charater, double significance, int tail)
        {
            //单样本总体比例的区间估计
            BigNumber count = new BigNumber("0");
            int len = NumberSeries.Length;
            for (int i=0;i < len ;i++)
            {if (CompareNumber.Compare(NumberSeries[i],charater) == 0)
              {
                count = count + new BigNumber("1");

              }
            else{
                count = count + new BigNumber("0");
            }
            }
            BigNumber proportion = count / new BigNumber(len.ToString());
            Console.WriteLine("计数是{0}", count.ToString());
            Console.WriteLine("比例是{0}", proportion.ToString());
            if (tail == 2)
            {
                significance = significance / 2;
                BigNumber lower = proportion - new BigNumber(NORMSINV(significance).ToString()) * ((proportion * (new BigNumber("1") - proportion)) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                BigNumber upper = proportion + new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString()))).Power(new BigNumber("0.5"));
                return lower.ToString() + "," + upper.ToString();
            }
            else
            {     significance = significance / 1;
                if (tail == 1)
                {
                    
                    BigNumber lower = proportion - new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString())).Power(new BigNumber("0.5")));
                    return lower.ToString() + ",";
                }
                else
                {
                    BigNumber upper = proportion + new BigNumber(NORMSINV(significance).ToString()) * (proportion * (new BigNumber("1") - proportion) / (new BigNumber(len.ToString())).Power(new BigNumber("0.5")));
                    return "," + upper.ToString();
                }
            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:40,代码来源:proportion+two+sample+(2).cs

示例12: HT2

        static string HT2(BigNumber H0, BigNumber[] NumberSeries1,BigNumber[] NumberSeries2, double significance, int tail)
        {
            //双样本总体均值假设检验
            string result = ParaEasti2(NumberSeries1,NumberSeries2, significance, tail);
            char[] separator = { ',' };
            string[] intervals = result.Split(separator);

            BigNumber one = new BigNumber("1");
            BigNumber mean1 = Mean(NumberSeries1);
            BigNumber mean2 = Mean(NumberSeries2);
            BigNumber var1 = Variance(NumberSeries1);
            BigNumber var2 = Variance(NumberSeries2);
            BigNumber n1 = new BigNumber(NumberSeries1.Length.ToString());
            BigNumber n2 = new BigNumber(NumberSeries2.Length.ToString());
            BigNumber S_p= ((n1-one)*var1 + (n2-one)*var2)/(n1+n2-one- one );
            BigNumber tvalue = (H0-(mean1-mean2))/S_p.Power(new BigNumber("0.5"),30);
            Double t_value = Convert.ToDouble(tvalue.ToString());
            BigNumber pvalue = new BigNumber(NORMSDIST(t_value).ToString());

            if (tail == 2) //H0 : mu1=mu2
            {
                BigNumber lower = new BigNumber(intervals[0]);
                BigNumber upper = new BigNumber(intervals[1]);
                if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
                {
                    return "P =" + pvalue.ToString() + "," + "不拒绝原假设";
                }
                else
                {
                    return "P =" + pvalue.ToString() + "," + "拒绝原假设";
                }
            }
            else
            {
                if (tail == 1)//H0:mu1>=mu2
                {   BigNumber lower = new BigNumber(intervals[0]);
                    if (CompareNumber.Compare(lower, H0) == -1 )
                    {
                        return "P =" + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "P =" + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                }
                else//H0:mu1<=mu2
                {
                    BigNumber upper = new BigNumber(intervals[1]);
                    if (CompareNumber.Compare(upper, H0) == 1)
                    {
                        return "P =" + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
                    }
                    else
                    {
                        return "P =" + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
                    }
                }

            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:60,代码来源:proportion+two+sample+(2).cs

示例13: HT

 static string HT(BigNumber H0, BigNumber[] NumberSeries, double significance, int tail)
 {
     //单样本总体均值假设检验
     string result = ParaEasti(NumberSeries, significance, tail);
     char[] separator = { ',' };
     string[] intervals = result.Split(separator);
    
     BigNumber mean_series = Mean(NumberSeries);
     BigNumber var_series = Variance(NumberSeries);
     BigNumber n = new BigNumber(NumberSeries.Length.ToString());
     BigNumber tvalue = (H0-mean_series)/((var_series/n).Power(new BigNumber("0.5"),10));
     
     Double t_value = Convert.ToDouble(tvalue.ToString());
     BigNumber pvalue = new BigNumber(NORMSDIST(t_value).ToString());
     //tail == 1右单尾,H0:x>= x_0,tail == -1 左单尾H0:x<= x_0,,为2则双尾
     if (tail == 2)
     {
         BigNumber lower = new BigNumber(intervals[0]);
         BigNumber upper = new BigNumber(intervals[1]);
         if (CompareNumber.Compare(lower, H0) == -1 && CompareNumber.Compare(upper, H0) == 1)
         {
             return "P = "+ pvalue.ToString() +","+"不拒绝原假设";
         }
         else
         {
             return "P = "+ pvalue.ToString() +","+"拒绝原假设";
         }
     }
     else
     {
         if (tail == 1)
         {
             BigNumber lower = new BigNumber(intervals[0]);
             if (CompareNumber.Compare(lower, H0) == -1 )
             {
                 return "P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
             }
             else
             {
                 return "P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "拒绝原假设";
             }
         }
         else
         {
             BigNumber lower = new BigNumber(intervals[1]);
             if (CompareNumber.Compare(lower, H0) == 1)
             {
                 return "P = " + (new BigNumber("2") * pvalue - new BigNumber("1")).ToString() + "," + "不拒绝原假设";
             }
             else
             {
                 return "P = "+ (new BigNumber("2")*pvalue- new BigNumber("1")).ToString()+ "," + "拒绝原假设";
             }
         }
     }
 }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:56,代码来源:proportion+two+sample+(2).cs

示例14: button_estimate_Click

 private void button_estimate_Click(object sender, EventArgs e)
 {
     string result = "";
     string[] WholeCI = new string[2];
     BigNumber Mean = new BigNumber("0"), Variance = new BigNumber("0");
     string DataNum = "";
     int DataNumCounts = 0;
     char[] separator = { ',' };
     int ColNum = 0;
     string Tail = "";
     
     if (comboBox_tail.Text == "左单尾"){
         Tail = "less";
     }
     else if(comboBox_tail.Text == "左单尾"){
         Tail = "greater";
     }
     else{
          Tail = "two";
     }
     double alpha = Convert.ToDouble(comboBox_Confidence.Text.Trim('%'));
      alpha = alpha / 100;
     BigNumber[][] NumberSeries = new BigNumber[Form1.S.dataGridView1.Rows.Count - 1][];
     //定义了一个锯齿数组
     int BigNumTimes = 0;
     if (comboBox_Method.Text.Trim() == "均值" || comboBox_Method.Text.Trim() == "比例"){
     if (textBox_ColShow.Text.Trim() != "")
     {
         string [] AllColsToRead = textBox_ColShow.Text.Trim().Split(separator);
         result = result + "置信度:"+comboBox_Confidence.Text+"\r\n"+Form1.S.AdjustStr("变量名") +"\t" +Form1.S.AdjustStr("样本数")+"\t"+Form1.S.AdjustStr("均值") +  "\t" +Form1.S.AdjustStr("标准差") + "\t" + Form1.S.AdjustStr("置信上限") + "\t" + Form1.S.AdjustStr("置信下限") + "\r\n";
         int UseToCount = 0;
         foreach (string SingleCol in AllColsToRead)
         {
             if (SingleCol.Trim() != "")
             {
                 DataNumCounts = 0;
                 DataNum = FindNAs(SingleCol.Trim());
                 //MessageBox.Show("黑名单:" + DataNum);
                 foreach (char DataRecord in DataNum)
                 {
                     if (DataRecord == 'N')
                     {
                         DataNumCounts++;
                     }
                 }
                 UseToCount++;
                 for (int i = 0; i < Form1.S.dataGridView1.ColumnCount; i++)
                 {
                     if (Form1.S.dataGridView1.Columns[i].Name == SingleCol)
                     {
                         ColNum = i;
                         break;
                     }
                 }
                 result = result + Form1.S.VariableNamePolish(Form1.S.dataGridView1.Columns[ColNum].HeaderCell.Value.ToString());
                 NumberSeries[BigNumTimes] = VectorReadASBigNum(SingleCol.Trim(),FindNAs(SingleCol.Trim()));
                 Mean = Stat.Mean(NumberSeries[BigNumTimes]);
                 result = result + "\t" + NumberSeries[BigNumTimes].Length.ToString().PadLeft(12, ' ') + "\t" + MathV.NumberPolish(Mean.ToString()).ToString().PadLeft(12, ' ') + "\t";
                 if (NumberSeries[BigNumTimes].Length == 1)
                 {
                     result = result + "NA".PadLeft(12, ' ') + "\t" + "NA".PadLeft(12, ' ') + "\t" +"NA".PadLeft(12, ' ');
                 }
                 else
                 {
                     Variance = Stat.Variance(NumberSeries[BigNumTimes]);
                     result = result +MathV.NumberPolish(Stat.Variance(NumberSeries[BigNumTimes]).Power(new BigNumber("0.5"), 30).ToString()).PadLeft(12, ' ');
                     //MessageBox.Show(result);
                     //MessageBox.Show("1-alpha = " + (1 - alpha).ToString() + "Tail " + Tail);
                     WholeCI = Stat.CI1(Mean,Variance,new BigNumber("-1"),new BigNumber(NumberSeries[BigNumTimes].Length.ToString()),1-alpha ,Tail,"Mean.Esti").Split(separator);
                     result = result +"\t"+MathV.NumberPolish(WholeCI[0])+"\t"+MathV.NumberPolish(WholeCI[1])+"\r\n";
                     //MessageBox.Show(result);
                  }
                
                 BigNumTimes++;
             }
         }
         textBox_result.Text = result;
     }
     }
 }
开发者ID:JoshuaHe2015,项目名称:VISAP_GUI,代码行数:80,代码来源:ParameterEstimation.cs

示例15: button_estimate_Click

        private void button_estimate_Click(object sender, EventArgs e)
        {
            string result = "";
            string[] WholeCI = new string[2];
            BigNumber Mean = new BigNumber("0"), Variance = new BigNumber("0");
            string DataNum = "";
            int DataNumCounts = 0;
            char[] separator = { ',' };
            int ColNum = 0;
            BigNumber[][] NumberSeries = new BigNumber[Form1.S.dataGridView1.Rows.Count - 1][];
            //定义了一个锯齿数组
            int BigNumTimes = 0;
            if (comboBox_Method.Text.Trim() == "均值" || comboBox_Method.Text.Trim() == "比例"){
            if (textBox_ColShow.Text.Trim() != "")
            {
                string [] AllColsToRead = textBox_ColShow.Text.Trim().Split(separator);
                result = result + "置信度:95%\r\n"+Form1.S.AdjustStr("变量名") +"\t" +Form1.S.AdjustStr("样本数")+"\t"+Form1.S.AdjustStr("均值") +  "\t" +Form1.S.AdjustStr("标准差") + "\t" + Form1.S.AdjustStr("置信上限") + "\t" + Form1.S.AdjustStr("置信下限") + "\r\n";
                int UseToCount = 0;
                foreach (string SingleCol in AllColsToRead)
                {
                    if (SingleCol.Trim() != "")
                    {
                        DataNumCounts = 0;
                        DataNum = FindNAs(SingleCol.Trim());
                        //MessageBox.Show("黑名单:" + DataNum);
                        foreach (char DataRecord in DataNum)
                        {
                            if (DataRecord == 'N')
                            {
                                DataNumCounts++;
                            }
                        }
                        UseToCount++;
                        for (int i = 0; i < Form1.S.dataGridView1.ColumnCount; i++)
                        {
                            if (Form1.S.dataGridView1.Columns[i].Name == SingleCol)
                            {
                                ColNum = i;
                                break;
                            }
                        }
                        //MessageBox.Show("BigNumTime = " + BigNumTimes + "SingleCol = " + SingleCol);
                        result = result + Form1.S.VariableNamePolish(Form1.S.dataGridView1.Columns[ColNum].HeaderCell.Value.ToString());
                        /*MessageBox.Show("result  = " + result);
                        int ii = 1;
                        foreach (BigNumber Num in VectorReadASBigNum(SingleCol.Trim(), FindNAs(SingleCol.Trim())))
                        {

                            MessageBox.Show("Num = " + Num+ "第"+ii+"次");
                            ii++;
                        }*/
                        NumberSeries[BigNumTimes] = VectorReadASBigNum(SingleCol.Trim(),FindNAs(SingleCol.Trim()));
                       
                        /*ii = 1;
                        foreach (BigNumber Num in NumberSeries[0])
                        {

                            MessageBox.Show("Num = " + Num + "第" + ii + "次");
                            ii++;
                        }*/
                        Mean = Stat.Mean(NumberSeries[BigNumTimes]);
                        result = result + "\t" + NumberSeries[BigNumTimes].Length.ToString().PadLeft(12, ' ') + "\t" + MathV.NumberPolish(Mean.ToString()).ToString().PadLeft(12, ' ') + "\t";
                        if (NumberSeries[BigNumTimes].Length == 1)
                        {
                            result = result + "NA".PadLeft(12, ' ') + "\t" + "NA".PadLeft(12, ' ') + "\t" +"NA".PadLeft(12, ' ');
                        }
                        else
                        {
                            Variance = Stat.Variance(NumberSeries[BigNumTimes]);
                            result = result +MathV.NumberPolish(Stat.Variance(NumberSeries[BigNumTimes]).Power(new BigNumber("0.5"), 30).ToString()).PadLeft(12, ' ');
                            WholeCI = Stat.CI1(Mean,Variance,new BigNumber("-1"),new BigNumber(NumberSeries[BigNumTimes].Length.ToString()),0.95,"two","Mean.Esti").Split(separator);
                            result = result +"\t"+MathV.NumberPolish(WholeCI[0])+"\t"+MathV.NumberPolish(WholeCI[1])+"\r\n";
                         }
                       
                        BigNumTimes++;
                    }
                }
                textBox_result.Text = result;
            }
            }
        }
开发者ID:Shotsordsoo,项目名称:VISAP_GUI,代码行数:81,代码来源:ParameterEstimation.cs


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