コード例 #1
0
        /// <summary>
        /// Выполнение сегментации исходного сигнала
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonGetQstSegments_Click(object sender, EventArgs e)
        {
            if (qstNoizebleSignalPoints == null || qstNoizebleSignalPoints.Count() == 0)
            {
                MessageBox.Show("Выполните зашумление исходного сигнала", "Ошибка!");
                return;
            }

            Meta.Numerics.Statistics.BivariateSample           bevar  = new Meta.Numerics.Statistics.BivariateSample();
            Dictionary <string, SignalUtilities.SegmentBounds> bounds = new Dictionary <string, SignalUtilities.SegmentBounds>();
            int discfrecuency = int.Parse(textBoxQstDiscFr.Text);

            foreach (var segment in qstSignal)
            {
                var segmentPoins  = DigitalSignalsGenerator.GetHarmonicSignal(segment.Harmonics, discfrecuency, segment.Time);
                var segmentBounds = SignalUtilities.GetSegment(qstNoizebleSignalPoints, segmentPoins);
                bounds.Add(segment.Name, segmentBounds);
            }

            DrawSegmentsAttributes(bounds, chartQstSignal);
        }
コード例 #2
0
        /// <summary>
        /// Вычисление нижнего и верхнего индексов сегмента в основном сигнале
        /// </summary>
        /// <param name="mainSignal"></param>
        /// <param name="segment"></param>
        /// <returns></returns>
        public static SegmentBounds GetSegment(double[] mainSignal, double[] segment)
        {
            int min, max;
            int step = segment.Length;

            double[] cutted;

            List <double> coeffs = new List <double>();

            Meta.Numerics.Statistics.BivariateSample bevar = new Meta.Numerics.Statistics.BivariateSample();

            for (int i = 0, j = step; j < mainSignal.Length; i++, j++)
            {
                cutted = mainSignal.Skip(i).Take(step).ToArray();
                bevar.Clear();
                bevar.Add(cutted, segment);
                coeffs.Add(bevar.PearsonRTest().Statistic.Value);
            }

            max = coeffs.IndexOf(coeffs.Max()) + step;
            min = coeffs.IndexOf(coeffs.Max());

            return(new SegmentBounds(min, max));
        }