コード例 #1
0
        /// <summary>
        /// Return a set of simulated bootstrap statistics that form the bootstrap distribution for medians via simulation given the original sample
        /// </summary>
        /// <param name="originalSample">The original sample</param>
        /// <param name="bootstrapSampleCount">The number of bootstrap samples collected to form the bootstrap distribution</param>
        /// <returns></returns>
        public static double[] SimulateSampleMedians(double[] originalSample, int bootstrapSampleCount)
        {
            double originalSampleMedian = Median.GetMedian(originalSample);
            double originalSampleStdDev = StdDev.GetStdDev(originalSample, originalSampleMedian);

            return(SimulateSampleMedians(originalSampleMedian, originalSampleStdDev, originalSample.Length, bootstrapSampleCount));
        }
コード例 #2
0
        /// <summary>
        /// Return a set of simulated bootstrap statistics that form the bootstrap distribution for medians via simulation given the original sample
        /// </summary>
        /// <param name="originalSampleMean">point estimate of sample mean from the original sample</param>
        /// <param name="originalSampleStdDev">standard deviation of the original sample</param>
        /// <param name="originalSampleSize">size of the original sample</param>
        /// <param name="bootstrapSampleCount">The number of bootstrap samples collected to form the bootstrap distribution</param>
        /// <returns></returns>
        public static double[] SimulateSampleMedians(double originalSampleMean, double originalSampleStdDev, int originalSampleSize, int bootstrapSampleCount)
        {
            Gaussian distribution = new Gaussian(originalSampleMean, originalSampleStdDev);

            double[] bootstrapMedians = new double[bootstrapSampleCount];

            double[] bootstrapSample = new double[originalSampleSize];
            for (int i = 0; i < bootstrapSampleCount; ++i)
            {
                for (int j = 0; j < originalSampleSize; ++j)
                {
                    bootstrapSample[j] = distribution.Next();
                }
                bootstrapMedians[i] = Median.GetMedian(bootstrapSample);
            }
            return(bootstrapMedians);
        }