Пример #1
0
        private void buttonCalc_Click(object sender, EventArgs e)
        {
            buttonCalc.Tag = "busy";
            ValuesAreOkay  = false;
            CalcSuccess    = false;

            // Read all numerical inout to strings
            string n_s = inputN.Text;
            string p_s = inputP.Text;
            string r_s = inputR.Text;
            string a_s = inputA.Text;

            VerifyValues(n_s, p_s, r_s, a_s);
            // Calls method to check variables parse and are within limits

            if (ValuesAreOkay)
            {
                NoTestSpec = false;

                string NullProbString = inputP.Text;
                radioButton1.Text = H1 + ":  p < " + NullProbString;
                radioButton2.Text = H1 + ":  p > " + NullProbString;
                radioButton3.Text = H1 + ":  p ≠ " + NullProbString;

                CalcSuccess = true;

                nValue = long.Parse(n_s);
                pValue = double.Parse(p_s);
                rValue = long.Parse(r_s);
                aValue = double.Parse(a_s);
                SetDefaultOutput(rValue);

                double P_XetR =
                    Maths.BinomialProb_XetR(nValue, pValue, rValue);
                string P_XetR_string = P_XetR.ToString("0.0000");
                text_P_XetR.Text += P_XetR_string;

                double P_XltR =
                    Maths.BinomialProb_XltR(nValue, pValue, rValue);
                string P_XltR_string = P_XltR.ToString("0.0000");
                text_P_XltR.Text += P_XltR_string;

                double P_XltetR =
                    Maths.BinomialProb_XltetR(nValue, pValue, rValue);
                string P_XltetR_string = P_XltetR.ToString("0.0000");
                text_P_XltetR.Text += P_XltetR_string;

                double P_XgtR =
                    Maths.BinomialProb_XgtR(nValue, pValue, rValue);
                string P_XgtR_string = P_XgtR.ToString("0.0000");
                text_P_XgtR.Text += P_XgtR_string;

                double P_XgtetR =
                    Maths.BinomialProb_XgtetR(nValue, pValue, rValue);
                string P_XgtetR_string = P_XgtetR.ToString("0.0000");
                text_P_XgtetR.Text += P_XgtetR_string;

                bool AltAcceptedBool =
                    Maths.IsAlternativeAccepted(testType, nValue, pValue, rValue, aValue);

                string stringAccept = "";
                string stringReject = "";
                if (AltAcceptedBool)
                {
                    stringAccept = "alternative";
                    stringReject = "null";
                }
                else
                {
                    stringAccept = "null";
                    stringReject = "alternative";
                }
                string stringHowAccept = "accepted";
                if (!AltAcceptedBool)
                {
                    stringHowAccept = "kept";
                }

                OutRejected.Text = "• The "
                                   + stringReject
                                   + " hypothesis has been rejected.";
                OutAccepted.Text = "• The "
                                   + stringAccept
                                   + " hypothesis has been "
                                   + stringHowAccept
                                   + ".";

                string OutConclusionString =
                    Strings.TestConclusion(false, "",
                                           testType, AltAcceptedBool, nValue, pValue);
                panelConclusion.Visible = true;

                OutConclusion.Text = OutConclusionString;
                Clipboard.SetText(OutConclusionString);
                // ^ Copy conclusion to clipboard

                string Comparison =
                    Strings.CriticalComparison(testType,
                                               nValue, pValue, rValue, aValue);

                OutComparisonValues.Text = Comparison;

                if (ShowExactValues)
                { // Exact values button has been clicked
                    string s1 = "P(X = x) = "
                                + P_XetR.ToString("0.00000000000000");
                    string s2 = "P(X < x) = "
                                + P_XltR.ToString("0.00000000000000");
                    string s3 = "P(X ≤ x) = "
                                + P_XltetR.ToString("0.00000000000000");
                    string s4 = "P(X > x) = "
                                + P_XgtR.ToString("0.00000000000000");
                    string s5 = "P(X ≥ x) = "
                                + P_XgtetR.ToString("0.00000000000000");

                    MessageBox.Show(s1 + "\n"
                                    + s2 + "\n"
                                    + s3 + "\n"
                                    + s4 + "\n"
                                    + s5,
                                    "Exact Values",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);

                    ShowExactValues = false;
                }
            }
            else
            {
                ValuesAreOkay   = false;
                ShowExactValues = false;
            }

            buttonCalc.Tag = "complete";
            headTitle.Focus();
        }