Esempio n. 1
0
        public static double LogNormal(double a, double b, double c)
        {
            double     x, y;
            Box_Muller box_Muller = new Box_Muller();

            y = box_Muller.RandomNormal(a, b);
            x = Math.Exp(y) + c;
            return(x);
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double Generate_Time = Convert.ToInt32(ExpCount.Text);

            double count = 0;

            Box_Muller box_Muller = new Box_Muller();
            double     tension    = 0;
            double     strength   = 0;

            for (int i = 1; i <= Generate_Time; i = i + 1)
            {
                switch (T_Type)
                {
                case "正态": tension = box_Muller.RandomNormal(Convert.ToDouble(T_N_mean.Text), Convert.ToDouble(T_N_variance.Text)); break;

                case "指数": tension = RandExp(Convert.ToDouble(T_E_lambda.Text)); break;

                case "威布尔": tension = Weibrand(Convert.ToDouble(T_W_a.Text), Convert.ToDouble(T_W_b.Text), Convert.ToDouble(T_W_c.Text)); break;

                case "对数正态": tension = LogNormal(Convert.ToDouble(T_LM_a.Text), Convert.ToDouble(T_LM_b.Text), Convert.ToDouble(T_LM_c.Text)); break;
                }
                switch (S_Type)
                {
                case "正态": strength = box_Muller.RandomNormal(Convert.ToDouble(S_N_mean.Text), Convert.ToDouble(S_N_variance.Text)); break;

                case "指数": strength = RandExp(Convert.ToDouble(S_E_lambda.Text)); break;

                case "威布尔": strength = Weibrand(Convert.ToDouble(S_W_a.Text), Convert.ToDouble(S_W_b.Text), Convert.ToDouble(S_W_c.Text)); break;

                case "对数正态": strength = LogNormal(Convert.ToDouble(S_LM_a.Text), Convert.ToDouble(S_LM_b.Text), Convert.ToDouble(S_LM_c.Text)); break;
                }
                if (tension < strength)
                {
                    count = count + 1;
                }
            }
            textBox5.Text = Convert.ToString(count / Generate_Time);
        }