Beispiel #1
0
 public void separacion(ref List<double> nNum, ref double fe)
 {
     if (Convert.ToInt32(textBox1.Text) < 12)
     {
         tableLayoutPanel1.AutoScroll = false;
     }
     else
     {
         tableLayoutPanel1.AutoScroll = true;
     }
     tableLayoutPanel1.Controls.Clear();
     int n = Convert.ToInt32(textBox1.Text);
     tableLayoutPanel1.ColumnCount = n;
     TableLayoutColumnStyleCollection styles = this.tableLayoutPanel1.ColumnStyles;
     foreach (ColumnStyle style in styles)
     {
         style.SizeType = SizeType.Percent;
         style.Width = 100 / n;
     }
     List<rango> nRang = new List<rango>();
     for (int i = 0; i < n; i++)
     {
         rango r = new rango();
         Label lb = new Label();
         lb.Text = fe.ToString();
         Label lab = new Label();
         Label cont = new Label();
         int valor = Convert.ToInt32(textBox5.Text);
         r.min = Math.Round((((i) * fe)/valor), 3);
         r.max = Math.Round((((i + 1) * fe) /valor) , 3);
         lab.Text = r.min.ToString() + " - " + r.max.ToString();
         cont.Text = "0";
         tableLayoutPanel1.Controls.Add(lb, i, 0);
         tableLayoutPanel1.Controls.Add(lab, i, 2);
         tableLayoutPanel1.Controls.Add(cont, i, 1);
         nRang.Add(r);
     }
     foreach (var y in nNum)
     {
         for (int i = 0; i < nRang.Count; i++)
         {
             if (nRang[i].min <= y && y < nRang[i].max)
             {
                 Label lab = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1);
                 lab.Text = (Convert.ToInt32(lab.Text) + 1).ToString();
             }
         }
     }
     label3.Text = nNum.Count.ToString();
     List<sumatoria> nSum = new List<sumatoria>();
     double storia = 0;
     for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++)
     {
         Label lb = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1);
         sumatoria s = new sumatoria();
         s.fo = Convert.ToDouble(lb.Text);
         nSum.Add(s);
         s.r = s.fo - fe;
         s.r = s.r * s.r;
         storia += s.r;
     }
     storia = (1.00 / fe) * storia;
     storia = Math.Round(storia, 5);
     textBox3.Text = storia.ToString();
 }
Beispiel #2
0
        public void separacion(ref List <double> nNum, ref double fe)
        {
            if (Convert.ToInt32(textBox1.Text) < 12)
            {
                tableLayoutPanel1.AutoScroll = false;
            }
            else
            {
                tableLayoutPanel1.AutoScroll = true;
            }
            tableLayoutPanel1.Controls.Clear();
            int n = Convert.ToInt32(textBox1.Text);

            tableLayoutPanel1.ColumnCount = n;
            TableLayoutColumnStyleCollection styles = this.tableLayoutPanel1.ColumnStyles;

            foreach (ColumnStyle style in styles)
            {
                style.SizeType = SizeType.Percent;
                style.Width    = 100 / n;
            }
            List <rango> nRang = new List <rango>();

            for (int i = 0; i < n; i++)
            {
                rango r  = new rango();
                Label lb = new Label();
                lb.Text = fe.ToString();
                Label lab   = new Label();
                Label cont  = new Label();
                int   valor = Convert.ToInt32(textBox5.Text);
                r.min     = Math.Round((((i) * fe) / valor), 3);
                r.max     = Math.Round((((i + 1) * fe) / valor), 3);
                lab.Text  = r.min.ToString() + " - " + r.max.ToString();
                cont.Text = "0";
                tableLayoutPanel1.Controls.Add(lb, i, 0);
                tableLayoutPanel1.Controls.Add(lab, i, 2);
                tableLayoutPanel1.Controls.Add(cont, i, 1);
                nRang.Add(r);
            }
            foreach (var y in nNum)
            {
                for (int i = 0; i < nRang.Count; i++)
                {
                    if (nRang[i].min <= y && y < nRang[i].max)
                    {
                        Label lab = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1);
                        lab.Text = (Convert.ToInt32(lab.Text) + 1).ToString();
                    }
                }
            }
            label3.Text = nNum.Count.ToString();
            List <sumatoria> nSum   = new List <sumatoria>();
            double           storia = 0;

            for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++)
            {
                Label     lb = (Label)tableLayoutPanel1.GetControlFromPosition(i, 1);
                sumatoria s  = new sumatoria();
                s.fo = Convert.ToDouble(lb.Text);
                nSum.Add(s);
                s.r     = s.fo - fe;
                s.r     = s.r * s.r;
                storia += s.r;
            }
            storia        = (1.00 / fe) * storia;
            storia        = Math.Round(storia, 5);
            textBox3.Text = storia.ToString();
        }