public double GetValue(List <DataPoint> sincValues, List <DataPoint> sampledValues)
        {
            List <DataPoint> valuesOne, valuesTwo;

            if (sincValues.Count > sampledValues.Count)
            {
                valuesOne = sincValues;
                valuesTwo = SignalUtils.AdjustSize(sampledValues, sincValues.Count);
            }
            else if (sincValues.Count < sampledValues.Count)
            {
                valuesOne = sampledValues;
                valuesTwo = SignalUtils.AdjustSize(sincValues, sampledValues.Count);
            }
            else
            {
                valuesOne = sampledValues;
                valuesTwo = sincValues;
            }

            double fraction = 1.0 / valuesOne.Count, sum = 0;

            for (int i = 0; i < valuesOne.Count; i++)
            {
                sum += Math.Pow(valuesOne[i].Y - valuesTwo[i].Y, 2);
            }
            return(Math.Round(fraction * sum, 4));
        }
示例#2
0
        public double GetValue(List <DataPoint> sincValues, List <DataPoint> sampledValues)
        {
            List <DataPoint> sinc, signal;

            if (sincValues.Count > sampledValues.Count)
            {
                sinc   = sincValues;
                signal = SignalUtils.AdjustSize(sampledValues, sincValues.Count);
            }
            else if (sincValues.Count < sampledValues.Count)
            {
                signal = sampledValues;
                sinc   = SignalUtils.AdjustSize(sincValues, sampledValues.Count);
            }
            else
            {
                signal = sampledValues;
                sinc   = sincValues;
            }

            var diff = Math.Abs(sinc[0].Y - signal[0].Y);

            for (int i = 1; i < sinc.Count; i++)
            {
                if (diff < Math.Abs(sinc[i].Y - signal[i].Y))
                {
                    diff = Math.Abs(sinc[i].Y - signal[i].Y);
                }
            }
            return(Math.Round(diff, 4));
        }
示例#3
0
        public double GetValue(List <DataPoint> sincValues, List <DataPoint> sampledValues)
        {
            List <DataPoint> sinc, signal;

            if (sincValues.Count > sampledValues.Count)
            {
                sinc   = sincValues;
                signal = SignalUtils.AdjustSize(sampledValues, sincValues.Count);
            }
            else if (sincValues.Count < sampledValues.Count)
            {
                signal = sampledValues;
                sinc   = SignalUtils.AdjustSize(sincValues, sampledValues.Count);
            }
            else
            {
                signal = sampledValues;
                sinc   = sincValues;
            }

            double numerator = 0, denominator = 0;

            for (int i = 0; i < sinc.Count; i++)
            {
                numerator   += Math.Pow(signal[i].Y, 2);
                denominator += Math.Pow(signal[i].Y - sinc[i].Y, 2);
            }

            return(Math.Round(10 * Math.Log10(numerator / denominator), 4));
        }
        public double GetValue(List <DataPoint> sincValues, List <DataPoint> sampledValues)
        {
            List <DataPoint> values;

            if (sincValues.Count > sampledValues.Count)
            {
                values = SignalUtils.AdjustSize(sampledValues, sincValues.Count);
            }
            else if (sincValues.Count < sampledValues.Count)
            {
                values = SignalUtils.AdjustSize(sincValues, sampledValues.Count);
            }
            else
            {
                values = sincValues;
            }

            double mse = SignalUtils.GetMeanSquareError(sincValues, sampledValues), numerator = values[0].Y;

            for (int i = 1; i < values.Count; i++)
            {
                if (values[i].Y > numerator)
                {
                    numerator = values[i].Y;
                }
            }

            return(Math.Round(10 * Math.Log10(numerator / mse), 4));
        }