コード例 #1
0
        internal static decimal[] EstimateBucketResolutions(
            long numSamples,
            double minSample,
            double maxSample,
            long valuesPerBucketTarget,
            bool isIntegerColumn)
        {
            if (numSamples <= 0)
            {
                throw new System.ArgumentException(
                          $"Argument numSamples should always be greater than zero, got {numSamples}.");
            }

            var range = maxSample - minSample;

            if (range <= 0)
            {
                return(new decimal[] { 1M });
            }

            var valueDensity = numSamples / (maxSample - minSample);

            var targetBucketSize = valuesPerBucketTarget / valueDensity;

            var bucketSizeEstimate = new BucketSize(isIntegerColumn
                ? System.Math.Max(targetBucketSize, 5)
                : targetBucketSize);

            return(new decimal[]
            {
                bucketSizeEstimate.Smaller(steps: 2).SnappedSize,
                bucketSizeEstimate.SnappedSize,
                bucketSizeEstimate.Larger(steps: 2).SnappedSize,
            });
        }
コード例 #2
0
        public void TestSmaller()
        {
            var b = new BucketSize(80);

            Assert.Equal(100M, b.SnappedSize);
            Assert.Equal(20M, b.Smaller(2).SnappedSize);
        }
コード例 #3
0
        public void TestSmallerOutOfBounds()
        {
            var b = new BucketSize(0.00022M);

            Assert.Equal(0.0002M, b.SnappedSize);
            Assert.Equal(0.0001M, b.Smaller(2).SnappedSize);
        }
コード例 #4
0
        public TlshBuilder(BucketSize bucketSize, ChecksumSize checksumSize)
        {
            bucketCount    = (int)bucketSize;
            checksumLength = (int)checksumSize;

            // Each bucket => 2 bits of output code.
            codeSize = bucketCount >> 2;

            slideWindow        = new int[CSlidingWindowSize];
            accumulatorBuckets = new uint[CBuckets];

            if (checksumLength > 1)
            {
                checksumArray = new int[checksumLength];
            }
        }
コード例 #5
0
        public static DateTime DecreaseDateTimeBy(DateTime toAdd, BucketSize bucketSize)
        {
            if (bucketSize == BucketSize.Day)
            {
                return(toAdd.AddDays(-1));
            }

            if (bucketSize == BucketSize.Month)
            {
                return(toAdd.AddMonths(-1));
            }

            if (bucketSize == BucketSize.Year)
            {
                return(toAdd.AddYears(-1));
            }

            throw new NotSupportedException("Unknown bucket size " + bucketSize);
        }
コード例 #6
0
        public bool IsTimeInBucket(DateTime toCheck, BucketSize bucketSize)
        {
            DateTime upperLimit = Time;

            if (bucketSize == BucketSize.Day)
            {
                upperLimit = upperLimit.AddDays(1);
            }
            else
            if (bucketSize == BucketSize.Month)
            {
                upperLimit = upperLimit.AddMonths(1);
            }
            else
            if (bucketSize == BucketSize.Year)
            {
                upperLimit = upperLimit.AddYears(1);
            }

            return(toCheck >= Time && toCheck < upperLimit);
        }
コード例 #7
0
ファイル: HistogramBucket.cs プロジェクト: edongashi/explorer
 internal HistogramBucket(decimal lowerBound, BucketSize bucketSize, NoisyCount noisyCount)
 {
     LowerBound      = lowerBound;
     BucketSize      = bucketSize;
     this.noisyCount = noisyCount;
 }
コード例 #8
0
        public void TestSnap200()
        {
            var b = new BucketSize(150);

            Assert.Equal(200M, b.SnappedSize);
        }
コード例 #9
0
        public void TestSnap100()
        {
            var b = new BucketSize(120M);

            Assert.Equal(100M, b.SnappedSize);
        }
コード例 #10
0
        public void TestSnapSecond()
        {
            var b = new BucketSize(0.00016M);

            Assert.Equal(0.0002M, b.SnappedSize);
        }
コード例 #11
0
        public void TestSnapFirst()
        {
            var b = new BucketSize(0.00014M);

            Assert.Equal(0.0001M, b.SnappedSize);
        }
コード例 #12
0
        public void TestSmallValue()
        {
            var b = new BucketSize(0.000001M);

            Assert.Equal(0.0001M, b.SnappedSize);
        }
コード例 #13
0
        public static DateTime RoundDateTimeDownToNearestBucketFloor(DateTime toRound, BucketSize bucketSize)
        {
            if (bucketSize == BucketSize.Day)
            {
                return(new DateTime(toRound.Year, toRound.Month, toRound.Day));
            }

            if (bucketSize == BucketSize.Month)
            {
                return(new DateTime(toRound.Year, toRound.Month, 1));
            }

            if (bucketSize == BucketSize.Year)
            {
                return(new DateTime(toRound.Year, 1, 1));
            }

            throw new NotSupportedException("Unknown bucket size " + bucketSize);
        }
コード例 #14
0
ファイル: TlshHash.cs プロジェクト: purutu/FFTriadBuddy
 private static int HashStringLength(BucketSize bucketSize, ChecksumSize checksumSize)
 {
     return(((int)bucketSize / 2) + ((int)checksumSize * 2) + 4);
 }