Beispiel #1
0
        //Verify DTMC: SPRT
        public bool verifyDTMC(SimulationNoMDP sml, out string report)
        {
            report = "";
            reSetRunTest();
            bool   result = sequentialProbRatioTest(sml);
            string st     = result ? "Hypothesis Accepted!" : "Hypothesis Rejected!";

            report += "\nSeqential Ration Plan Result:\n" + sprtcount + "/" + sprttotal + "\n" + st;
            return(result);
        }
Beispiel #2
0
 //Verify MDP based on several DTMC: SSP
 public bool verifyMDPSSP(SimulationNoMDP sml, Policy policy, out string report)
 {
     report = null;
     policy.reSetPlan();
     while (policy.hasPolicy())
     {
         reSetRunTest();
         report += policy.reportAdversary(policy.updatePolicy());
         bool   result = singleSamplingTest(sml);
         string st     = result ? "Hypothesis Accepted!" : "Hypothesis Rejected!";
         report += "\nSingle Sampling Plan Result:\n" + sprtcount + "/" + sprttotal + "\n" + st;
         if (!result)
         {
             return(false);
         }
     }
     return(true);
 }
Beispiel #3
0
        //Verify CTMC: sequential single sampling(SSP)  testrequires to calculate fixed sample size
        public bool singleSamplingTest(SimulationNoMDP sml)
        {
            //ssp.SSPAlgSpefic(paraStat.theta, paraStat.sigma, paraStat.alpha, paraStat.beta);
            sml.trials = ssp.minSmpSize;
            long m = 0, dm = 0;

            while (dm <= ssp.minTruthSize && (dm + ssp.minSmpSize - m) > ssp.minTruthSize)
            {
                m++;
                if (sml.getsingleTrial())
                {
                    dm++;
                }
            }
            sprttotal = m;
            sprtcount = dm;
            return(dm > ssp.minTruthSize ? true : false);
        }
Beispiel #4
0
        //Verify MDP based on several DTMC: SPRT
        public bool verifyMDPSPRT(SimulationNoMDP sml, Policy policy, out string report)
        {
            report = null;
            policy.reSetPlan();
            while (policy.hasPolicy())
            {
                reSetRunTest();
                report += policy.reportAdversary(policy.updatePolicy());
                bool result = sequentialProbRatioTest(sml);

                // following two statements only used for
                string st = result ? "Hypothesis Accepted!" : "Hypothesis Rejected!";
                report += "\nSeqential Ration Plan Result:\n" + sprtcount + "/" + sprttotal + "\n" + st;
                if (!result)
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        //Verify DTMC: sequential probability ratio sampling test(SPRST) doesn't require to calculate fixed sample size: on the fly
        public bool sequentialProbRatioTest(SimulationNoMDP sml)
        {
            double p0 = theta + sigma;
            double p1 = theta - sigma;
            double a  = alpha;
            double b  = beta;

            if (p0 == 1 && p1 == 0)
            {
                // ssp.SSPAlgSpefic(paraStat.beta, paraStat.sigma, paraStat.alpha, paraStat.beta);
                return(singleSamplingTest(sml));
            }
            long   m      = 0;
            double fm     = 0;
            double bound1 = Math.Log((b / (1 - a)));
            double bound2 = Math.Log((1 - b) / a);

            while (fm > bound1 && fm < bound2)
            {
                m++;
                long dm;
                if (sml.getsingleTrial())
                {
                    dm = 1;
                    sprtcount++;
                }
                else
                {
                    dm = 0;
                }
                fm += dm * Math.Log(p1 / p0) + (1 - dm) * Math.Log((1 - p1) / (1 - p0));
            }
            sprttotal = m;
            return(fm <= bound1 ? true : false);
            //if false, that means fm>=bound2(notice while loop)
        }