Example #1
0
        private void ocjenaFunkcija(PosrednoIzjednacenje mnk)
        {
            foreach (ListViewItem item in lvA.Items)
            {
                ListViewItem  ocjena = new ListViewItem(item.SubItems[0].Text);
                List <double> hLista = new List <double>();

                for (int i = 1; i < item.SubItems.Count; i++)
                {
                    hLista.Add(Convert.ToDouble(item.SubItems[i].Text));
                }

                DenseVector h = new DenseVector(hLista.ToArray());

                OcjenjivostFunkcija funk = new OcjenjivostFunkcija(h, mnk.Qx, mnk.N);

                if (funk.FunkcijaJeOcjeniva)
                {
                    ocjena.SubItems.Add("DA");
                }
                else
                {
                    ocjena.SubItems.Add("-NE-");
                }

                double sigmaNulaKvadrat = Convert.ToDouble(tbSigmaNulaKvadrat.Text, CultureInfo.InvariantCulture);

                ocjena.SubItems.Add(funk.s(sigmaNulaKvadrat).ToString());
                ocjena.SubItems.Add(Math.Sqrt(funk.s(sigmaNulaKvadrat)).ToString());

                lvOcjenaFunkcija.Items.Add(ocjena);
            }

            for (int i = 1; i < lvA.Columns.Count; i++)
            {
                DenseVector h = new DenseVector(lvA.Columns.Count - 1);
                h[i - 1] = 1;

                ListViewItem        ocjena = new ListViewItem(lvA.Columns[i].Text);
                OcjenjivostFunkcija funk   = new OcjenjivostFunkcija(h, mnk.Qx, mnk.N);

                if (funk.FunkcijaJeOcjeniva)
                {
                    ocjena.SubItems.Add("DA");
                }
                else
                {
                    ocjena.SubItems.Add("-NE-");
                }

                double sigmaNulaKvadrat = Convert.ToDouble(tbSigmaNulaKvadrat.Text, CultureInfo.InvariantCulture);

                ocjena.SubItems.Add(funk.s(sigmaNulaKvadrat).ToString());
                ocjena.SubItems.Add(Math.Sqrt(funk.s(sigmaNulaKvadrat)).ToString());
                lvOcjenaFunkcija.Items.Add(ocjena);
            }
        }
Example #2
0
        private void prikaz(PosrednoIzjednacenje mnk)
        {
            MatrixVectorAndControls mvc = new MatrixVectorAndControls();

            double dd = mnk.N[1, 1];

            StatusStrip(mnk);


            ListView N = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "N", N, mnk.N, mvc.ListViewColumnHeaderToList(lvA), mvc.ListViewColumnHeaderToList(lvA));

            ListView n = new ListView();

            mvc.VectorToTabPage(tcIzjednacenje, "n", n, mnk.n, "n", mvc.ListViewColumnHeaderToList(lvA));

            ListView Qx = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "Qx", Qx, mnk.Qx, mvc.ListViewColumnHeaderToList(lvA), mvc.ListViewColumnHeaderToList(lvA));

            ListView x2d = new ListView();

            mvc.VectorToTabPage(tcIzjednacenje, "x", x2d, mnk.x, "x", mvc.ListViewColumnHeaderToList(lvA));

            ListView v = new ListView();

            mvc.VectorToTabPage(tcIzjednacenje, "v", v, mnk.v, "v", mvc.ListViewColumnHeaderToList(lvP));

            ListView Qlcap = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "Qî", Qlcap, mnk.Qlcap, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView Qv = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "Qv", Qv, mnk.Qv, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView Ql = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "Ql", Ql, mnk.Ql, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView R = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "R", R, mnk.R, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView U = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "U", U, mnk.U, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView RU = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "R + U = I", RU, mnk.R + mnk.U, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));
        }
Example #3
0
        private void StatusStrip(PosrednoIzjednacenje mnk)
        {
            if (rbIzjednacenjePrisila.Checked)
            {
                tsslVrstaIzjednacenja.Text = rbIzjednacenjePrisila.Text;
            }
            if (rbKlasicanNacin.Checked)
            {
                tsslVrstaIzjednacenja.Text = rbKlasicanNacin.Text;
            }
            if (rbMinimalniTrag.Checked)
            {
                tsslVrstaIzjednacenja.Text = rbMinimalniTrag.Text;
            }
            if (rbParcijalniMinimalniTrag.Checked)
            {
                tsslVrstaIzjednacenja.Text = rbParcijalniMinimalniTrag.Text;
            }

            tsslSigmaKvadrat.Text = "    σ²: " + tbSigmaNulaKvadrat.Text;
            tsslSigma.Text        = "    σ: " + tbSigmaNula.Text;
            tsslSo2.Text          = "    s²: " + mnk.sKvadrat.ToString();
            tsslSo.Text           = "    s: " + Math.Sqrt(mnk.sKvadrat).ToString();

            int u = mnk.N.ColumnCount;
            int n = mnk.Ql.ColumnCount;
            int f, d;

            if (lvG.Items.Count == 0)
            {
                d = 0;
                f = n - u + d;
            }
            else
            {
                d = 1;
                f = n - u + d;
            }

            tssln.Text = "    n: " + n.ToString();
            tsslu.Text = "    u: " + u.ToString();
            tssld.Text = "    d: " + d.ToString();
            tsslf.Text = "    f: " + f.ToString();
        }
Example #4
0
        public void PosrednoIzjednacenje_Izjednacenje_s_uvjetima_ReturnsTrue()
        {
            double[] Amat = new double[] { -0.642344123, -5.17955E-17, -1.55387E-16, 0, 0, 0, 0, 0, 0, -0.642344123, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.183885858, 0.845912664, 0.845912664, 0, 0, 0, 0, 0, 0, 0.183885858, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5.17955E-17, 1.55387E-16, -1.32881232, -0.906530679, -0.906530679, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, -0.845912664, -0.845912664, 0.822717088, 0.244355575, 0.244355575, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0.906530679, 0.906530679, -0.324334263, -0.324334263, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.244355575, -0.244355575, -0.827598226, -0.827598226, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0.642344123, 0, 0, 0, 0, 0, 0.324334263, 0.324334263, 0.441609708, 0.642344123, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, -0.183885858, 0, 0, 0, 0, 0, 0.827598226, 0.827598226, 0.546328096, -0.183885858, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 1.32881232, 0, 0, 0, 0, -0.441609708, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, -0.822717088, 0, 0, 0, 0, -0.546328096, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

            double[] Pmat = new double[] { 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.223960382, -0.132721579, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.132721579, 0.182710655, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.259752624, -0.16411805, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.16411805, 0.240868003, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.259731312, -0.184607637, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.184607637, 0.304823553, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.182720355, -0.148661281, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.148661281, 0.280950818, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.304872496, -0.208742568, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.208742568, 0.331959467, };


            double[] fvec = new double[] { -1.510825038, 1.510825038, 0.840855955, -2.678903659, 1.838047704, 1.275577044, -1.275577044, -0.326921245, -2.878469774, 3.205391019, -2, -1, -1, -3, 2, 2, -5.68434E-11, -2, -3, 3 };


            double[] Gmat = new double[] { 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0, 0, 0, 0, 0, 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0.447213595, 0, 0, 0, 0 };

            DenseMatrix A = new DenseMatrix(20, 14, Amat);
            DenseMatrix P = new DenseMatrix(20, 20, Pmat);
            DenseVector f = new DenseVector(fvec);
            DenseMatrix G = new DenseMatrix(14, 2, Gmat);

            PosrednoIzjednacenje izjednacenje = new PosrednoIzjednacenje(A, P, f, G);

            double test = 1.2701386915 - izjednacenje.sKvadrat;

            // tocnost test vrijednostije na 1 decimala
            Assert.IsTrue(test < Math.Pow(10, 10), "s2: " + test);
        }
Example #5
0
        public Statistika(PosrednoIzjednacenje mnk, double sigmaNulaKvadrat, double alfa, double beta, int f, double alfaGlob)
        {
            this.alfa = alfa;
            this.beta = beta;
            this.f    = f;
            this.mnk  = mnk;


            baarda  = new LokalniTestDataSnooping(sigmaNulaKvadrat, mnk.v, mnk.Ql, mnk.R, alfa, beta);
            tauTest = new LokalniTestTau(mnk.sKvadrat, mnk.v, mnk.Qv, alfa, f);
            Gi(sigmaNulaKvadrat);

            globTest = new GlobalniTest(sigmaNulaKvadrat, mnk.sKvadrat, f, alfaGlob);
            gtest    = "Globalni test: " + globTest.Minimum.ToString() + " < " + sigmaNulaKvadrat.ToString() + " < " + globTest.Maximum.ToString() + " : ";

            if (globTest.TestProlazi)
            {
                gtest = gtest + " OK";
            }
            else
            {
                gtest = gtest + " Pad testa :(";
            }
        }
Example #6
0
        private void Izjednacenje()
        {
            tcIzjednacenje.TabPages.Clear();
            lvOcjenaFunkcija.Items.Clear();

            PosrednoIzjednacenje    MNK;
            MatrixVectorAndControls mvc = new MatrixVectorAndControls();


            DenseMatrix A = mvc.ListViewToMatrix(lvA);
            DenseMatrix P = mvc.ListViewToMatrix(lvP);
            DenseVector f = mvc.ListViewToVector(lvF);
            DenseMatrix G;

            int fprekobrojnost = Math.Abs(A.ColumnCount - A.RowCount);

            if (lvG.Items.Count == 0)
            {
                MNK = new PosrednoIzjednacenje(A, P, f);
            }
            else
            {
                G   = mvc.ListViewToMatrix(lvG);
                MNK = new PosrednoIzjednacenje(A, P, f, G);
                fprekobrojnost++;
            }

            ListView Alv = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "A", Alv, A, mvc.ListViewColumnHeaderToList(lvA), mvc.ListViewColumnHeaderToList(lvP));

            ListView Plv = new ListView();

            mvc.MatrixToTabPage(tcIzjednacenje, "P", Plv, P, mvc.ListViewColumnHeaderToList(lvP), mvc.ListViewColumnHeaderToList(lvP));

            ListView flv = new ListView();

            mvc.VectorToTabPage(tcIzjednacenje, "f", flv, f, "", mvc.ListViewColumnHeaderToList(lvP));



            prikaz(MNK);
            ocjenaFunkcija(MNK);

            izjednaceneVrijednosti izjednaceno = new izjednaceneVrijednosti(MNK);

            izjednaceno.lvMjerenja(lvIzjednacenaMjerenja, lvMjerenje, Convert.ToDouble(tbSigmaNulaKvadrat.Text, CultureInfo.InvariantCulture));
            izjednaceno.lvReperi(lvReperi, lvTocke, Convert.ToDouble(tbSigmaNulaKvadrat.Text, CultureInfo.InvariantCulture), rbIzjednacenjePrisila.Checked);

            double alfa     = Convert.ToDouble(tbLokalniAlfa.Text, CultureInfo.InvariantCulture) / 100;
            double beta     = Convert.ToDouble(tbLokalniBeta.Text, CultureInfo.InvariantCulture) / 100;
            double alfaGlob = Convert.ToDouble(tbGlobalniAlfa.Text, CultureInfo.InvariantCulture) / 100;


            Statistika test = new Statistika(MNK, Convert.ToDouble(tbSigmaNulaKvadrat.Text, CultureInfo.InvariantCulture), alfa, beta, fprekobrojnost, alfaGlob);

            test.LokalniTest(lvStatistika, lvP);

            tsslGlobalniTest.Text = test.Gtest;
            tsslGlobalniTest.Text = test.Gtest;
        }
Example #7
0
        //double sigmaNulaKvadrat = 0;



        public izjednaceneVrijednosti(PosrednoIzjednacenje mnk)
        {
            this.mnk = mnk;
            //this.sigmaNulaKvadrat = sigmaNulaKvadrat;
        }