internal static double GetMaxRatio(ChartValues <ObservablePoint> sincValues, ChartValues <ObservablePoint> signalValues) { ChartValues <ObservablePoint> values; if (sincValues.Count > signalValues.Count) { values = MathLogics.AdjustSize(signalValues, sincValues.Count); } else if (sincValues.Count < signalValues.Count) { values = MathLogics.AdjustSize(sincValues, signalValues.Count); } else { values = sincValues; } double mse = ResultLogics.GetMeanSquareError(sincValues, signalValues), 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)); }
internal static string[] GetHistogramLabels(ChartValues <ObservablePoint> samples, int howManySections = 10) { string[] result = new string[howManySections + 1]; double[] minMax = MathLogics.GetMinMax(samples); double step = Math.Abs(minMax[1] - minMax[0]) / howManySections; for (int i = 0; i < howManySections + 1; i++) { result[i] = "(" + Math.Round(minMax[0] + (i) * step, 3) + "; " + Math.Round(minMax[0] + (i + 1) * step, 3) + ")"; } return(result); }
internal static double GetSincReconstructionValue(IEnumerable <ObservablePoint> samples, double time, double frequency) { double result = 0.0, T = 1.0 / frequency, helpMe; //int counter = 0; foreach (var item in samples) { helpMe = time / T - (item.X / T); result += item.Y * MathLogics.Sinc(helpMe); //counter++; } //for(int i = 0; i < samples; i++) //{ // helpMe = time / T - i; // result += samples[i].Y * MathLogics.Sinc(helpMe); //} return(result); }
internal static double GetMaxDiffrence(ChartValues <ObservablePoint> sincValues, ChartValues <ObservablePoint> signalValues) { ChartValues <ObservablePoint> sinc, signal, a; if (sincValues.Count > signalValues.Count) { sinc = sincValues; signal = MathLogics.AdjustSize(signalValues, sincValues.Count); } else if (sincValues.Count < signalValues.Count) { signal = signalValues; sinc = MathLogics.AdjustSize(sincValues, signalValues.Count); } else { signal = signalValues; sinc = sincValues; } if (signal.Count > sinc.Count) { a = sinc; } else { a = signal; } double diff = Math.Abs(sinc[0].Y - signal[0].Y); for (int i = 1; i < a.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)); }
internal static double GetRatio(ChartValues <ObservablePoint> sincValues, ChartValues <ObservablePoint> signalValues) { ChartValues <ObservablePoint> sinc, signal, a; if (sincValues.Count > signalValues.Count) { sinc = sincValues; signal = MathLogics.AdjustSize(signalValues, sincValues.Count); } else if (sincValues.Count < signalValues.Count) { signal = signalValues; sinc = MathLogics.AdjustSize(sincValues, signalValues.Count); } else { signal = signalValues; sinc = sincValues; } if (signal.Count > sinc.Count) { a = sinc; } else { a = signal; } double numerator = 0, denominator = 0; for (int i = 0; i < a.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)); }
internal static double GetMeanSquareError(ChartValues <ObservablePoint> sincValues, ChartValues <ObservablePoint> signalValues) { ChartValues <ObservablePoint> valuesOne, valuesTwo, a; if (sincValues.Count > signalValues.Count) { valuesOne = sincValues; valuesTwo = MathLogics.AdjustSize(signalValues, sincValues.Count); } else if (sincValues.Count < signalValues.Count) { valuesOne = signalValues; valuesTwo = MathLogics.AdjustSize(sincValues, signalValues.Count); } else { valuesOne = signalValues; valuesTwo = sincValues; } if (valuesOne.Count > valuesTwo.Count) { a = valuesTwo; } else { a = valuesOne; } 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)); }
internal static double GetAveragePower(ChartValues <ObservablePoint> values) { return(Math.Round(MathLogics.Sum(values, v => Math.Pow(v, 2)) / values.Count, 4)); }
internal static double GetVariation(ChartValues <ObservablePoint> values) { return(Math.Round(MathLogics.Sum(values, v => Math.Pow(v - ResultLogics.GetAverage(values), 2)) / values.Count, 4)); }