Beispiel #1
0
        public void Run()
        {
            var random = new RandomDistribution(42);
            var data   = new List <double>();

            data.AddRange(random.Gaussian(200, mean: 20, stdDev: 1));
            data.AddRange(random.Gaussian(200, mean: 22, stdDev: 1));

            const double binSize = 0.5;

            Console.WriteLine("*** Simple Histogram ***");
            Console.WriteLine(SimpleHistogramBuilder.Instance.Build(data, binSize).ToString());
            Console.WriteLine("*** Adaptive Histogram ***");
            Console.WriteLine(AdaptiveHistogramBuilder.Instance.Build(data, binSize).ToString());
        }
        public void Run()
        {
            var       random = new RandomDistribution(42);
            var       data   = new List <double>();
            const int n      = 20;

            for (int i = 0; i < n; i++)
            {
                data.AddRange(random.Gaussian(100, mean: 20 * i, stdDev: 5));
            }

            var rqqIndexes = RqqPeltChangePointDetector.Instance.GetChangePointIndexes(data.ToArray());
            var edIndexes  = EdPeltChangePointDetector.Instance.GetChangePointIndexes(data.ToArray());

            Console.WriteLine("RqqPelt  EdPelt");
            for (int i = 0, j = 0, k = 1; k < n; k++)
            {
                string rqqIndex = "-", edIndex = "-";
                if (i < rqqIndexes.Length && rqqIndexes[i] < k * 100 + 10)
                {
                    rqqIndex = rqqIndexes[i++].ToString();
                }
                if (j < edIndexes.Length && edIndexes[j] < k * 100 + 10)
                {
                    edIndex = edIndexes[j++].ToString();
                }
                Console.WriteLine($"{rqqIndex.PadLeft(7)} {edIndex.PadLeft(6)}");
            }
        }
Beispiel #3
0
        public void BimodalProgression(int count, int meanFactor, int stdDev, int error)
        {
            var random   = new RandomDistribution(42);
            var shuffler = new Shuffler(42);

            var data = new List <double>();

            for (int i = 0; i < count; i++)
            {
                data.AddRange(random.Gaussian(30, 0, stdDev));
                data.AddRange(random.Gaussian(70, (i + 1) * meanFactor, stdDev));
                shuffler.Shuffle(data, i * 100, 100);
            }

            var indexes = detector.GetChangePointIndexes(data.ToArray(), 20);

            Check100(count, error, indexes);
        }
Beispiel #4
0
        public void GaussianMeanProgression(int count, int meanFactor, int stdDev, int error)
        {
            var random = new RandomDistribution(42);

            var data = new List <double>();

            for (int i = 0; i < count; i++)
            {
                data.AddRange(random.Gaussian(100, mean: meanFactor * i, stdDev: stdDev));
            }

            var indexes = detector.GetChangePointIndexes(data.ToArray(), 20);

            Check100(count, error, indexes);
        }
Beispiel #5
0
        public void GaussianStdDevProgression(int error, [NotNull] string stdDevValuesString)
        {
            var random = new RandomDistribution(42);

            var stdDevValues = stdDevValuesString.Split(';').Select(double.Parse).ToArray();
            var data         = new List <double>();

            foreach (double stdDev in stdDevValues)
            {
                data.AddRange(random.Gaussian(100, mean: 0, stdDev: stdDev));
            }

            var indexes = detector.GetChangePointIndexes(data.ToArray(), 20);

            Check100(stdDevValues.Length, error, indexes);
        }
Beispiel #6
0
        public void Run()
        {
            var random = new RandomDistribution(42);
            var data   = new List <double>();

            data.AddRange(random.Gaussian(200, mean: 20));
            data.AddRange(random.Gaussian(200, mean: 22));
            List <double>
            unimodal     = new List <double>(),
                bimodal  = new List <double>(),
                trimodal = new List <double>();

            unimodal.AddRange(random.Gaussian(200, mean: 20));
            bimodal.AddRange(random.Gaussian(200, mean: 20));
            bimodal.AddRange(random.Gaussian(200, mean: 30));
            trimodal.AddRange(random.Gaussian(200, mean: 20));
            trimodal.AddRange(random.Gaussian(200, mean: 30));
            trimodal.AddRange(random.Gaussian(200, mean: 40));
            Console.WriteLine("Unimodal : " + MValueCalculator.Calculate(unimodal));
            Console.WriteLine("Bimodal  : " + MValueCalculator.Calculate(bimodal));
            Console.WriteLine("Trimodal : " + MValueCalculator.Calculate(trimodal));
        }