コード例 #1
0
 public double Correlation(DynamicBin1D other)
 {
     lock (syncLock)
     {
         return(Covariance(other) / (StandardDeviation() * other.StandardDeviation()));
     }
 }
コード例 #2
0
        public override Object Clone()
        {
            DynamicBin1D clone = (DynamicBin1D)base.Clone();

            if (this._elements != null)
            {
                clone._elements = clone._elements.Copy();
            }
            if (this.SortedElements != null)
            {
                clone.SortedElements = clone.SortedElements.Copy();
            }
            return(clone);
        }
コード例 #3
0
        public double Covariance(DynamicBin1D other)
        {
            lock (syncLock)
            {
                if (Size != other.Size)
                {
                    throw new ArgumentException("both bins must have same Size");
                }
                double s = 0;
                for (int i = Size; --i >= 0;)
                {
                    s += this._elements[i] * other._elements[i];
                }

                double cov = (s - Sum * other.Sum / Size) / Size;
                return(cov);
            }
        }
コード例 #4
0
        public double Covariance(DynamicBin1D other)
        {
            lock (syncLock)
            {
                if (Size != other.Size)
                {
                    throw new ArgumentException(Cern.LocalizedResources.Instance().Exception_BothBinsMustHaveSameSize);
                }
                double s = 0;
                for (int i = Size; --i >= 0;)
                {
                    s += this._elements[i] * other._elements[i];
                }

                double cov = (s - Sum * other.Sum / Size) / Size;
                return(cov);
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        public override Boolean Equals(Object obj)
        {
            if (!(obj is DynamicBin1D))
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }

            DynamicBin1D other = (DynamicBin1D)obj;

            double[] s1 = sortedElements_unsafe().ToArray();
            lock (syncLock)
            {
                double[] s2 = other.sortedElements_unsafe().ToArray();
                int      n  = Size;
                return(Includes(s1, s2, 0, n, 0, n) &&
                       Includes(s2, s1, 0, n, 0, n));
            }
        }