private List <double> RunSingle(RqqPeltChangePointDetector detector, IReadOnlyList <CpdTestData> dataSet, bool printReports)
        {
            int maxNameLength = dataSet.Select(data => data.Name.Length).Max();

            var penalties = new List <double>();

            Parallel.ForEach(dataSet, testData =>
            {
                var changePointIndexes = detector.GetChangePointIndexes(testData.Values.ToArray());
                var verification       = CpdTestDataVerification.Verify(testData, changePointIndexes);
                lock (detector)
                {
                    penalties.Add(verification.Penalty);
                    PrintLine($"{testData.Name.PadRight(maxNameLength)} : {verification.Penalty}");
                    if (printReports)
                    {
                        PrintLine(verification.Report);
                    }
                }
            });

            PrintLine("  Sum  = " + penalties.Sum());
            PrintLine("  Max  = " + penalties.Max());
            foreach (double p in new[] { 0.5, 0.90, 0.99 })
            {
                string metric   = $"P{p * 100}".PadRight(4);
                double estimate = HarrellDavisQuantileEstimator.Instance.GetQuantile(penalties, p);
                PrintLine($"  {metric} = {estimate:0.##}");
            }

            return(penalties);
        }
Beispiel #2
0
        public void ReferenceDataSetTest(string name)
        {
            var cpdTestData  = ReferenceDataSet.First(d => d.Name == name);
            var indexes      = detector.GetChangePointIndexes(cpdTestData.Values.ToArray(), 20);
            var verification = CpdTestDataVerification.Verify(cpdTestData, indexes);

            output.WriteLine(verification.Report);
            output.WriteLine("Max penalty: " + verification.Penalty);
            Assert.True(verification.Penalty <= CpdTestData.PenaltyValues.Default.ExtraPoint * 2);
        }