Beispiel #1
0
        public DynamicBin1D SampleBootstrap(DynamicBin1D other, int resamples, Cern.Jet.Random.Engine.RandomEngine randomGenerator, BinBinFunction1D function)
        {
            if (randomGenerator == null)
            {
                randomGenerator = Cern.Jet.Random.Uniform.MakeDefaultGenerator();
            }

            // since "resamples" can be quite large, we care about performance and memory
            int MaxCapacity = 1000;
            int s1          = Size;
            int s2          = other.Size;

            // prepare auxiliary bins and buffers
            DynamicBin1D sample1 = new DynamicBin1D();

            Cern.Colt.Buffer.DoubleBuffer buffer1 = sample1.Buffered(System.Math.Min(MaxCapacity, s1));

            DynamicBin1D sample2 = new DynamicBin1D();

            Cern.Colt.Buffer.DoubleBuffer buffer2 = sample2.Buffered(System.Math.Min(MaxCapacity, s2));

            DynamicBin1D bootstrap = new DynamicBin1D();

            Cern.Colt.Buffer.DoubleBuffer bootBuffer = bootstrap.Buffered(System.Math.Min(MaxCapacity, resamples));

            // resampling steps
            for (int i = resamples; --i >= 0;)
            {
                sample1.Clear();
                sample2.Clear();

                this.Sample(s1, true, randomGenerator, buffer1);
                other.Sample(s2, true, randomGenerator, buffer2);

                bootBuffer.Add(function(sample1, sample2));
            }
            bootBuffer.Flush();
            return(bootstrap);
        }
Beispiel #2
0
        /// <summary>
        /// Make a copy of this object
        /// </summary>
        /// <returns></returns>
        public override RandomEngine Clone()
        {
            RandomEngine copy = (RandomEngine)this.MemberwiseClone();

            return(copy);
        }