Example #1
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);
        }
Example #2
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)
        }