Beispiel #1
0
        internal DataCapsule Correlation(DataCapsule dataCapsule)
        {
            ChartValues <ObservablePoint> correlationValues = new ChartValues <ObservablePoint>();

            double frequency = (this.XValues.Max() + dataCapsule.XValues.Max()) / (this.XValues.Count + dataCapsule.XValues.Count - 1);
            int    counter   = 0;

            double[] time = SignalLogics.GetTimeValues(frequency, this.XValues.Max() + dataCapsule.XValues.Max());

            for (int i = 0; i < this.XValues.Count + dataCapsule.XValues.Count - 1; i++)
            {
                Complex sum   = Complex.Zero;
                int     k1min = i >= dataCapsule.XValues.Count - 1 ? i - (dataCapsule.XValues.Count - 1) : 0,
                        k1max = i < this.XValues.Count - 1 ? i : this.XValues.Count - 1,
                        k2min = i <= dataCapsule.XValues.Count - 1 ? dataCapsule.XValues.Count - 1 - i : 0;

                for (int k1 = k1min, k2 = k2min; k1 <= k1max; k1++, k2++)
                {
                    sum += this.YValues[k1] * dataCapsule.YValues[k2];
                }
                correlationValues.Add(new ObservablePoint {
                    X = time[counter], Y = sum.Real
                });
                counter++;
            }

            return(new DataCapsule(correlationValues, dataCapsule.SamplingFrequency));
        }
Beispiel #2
0
        internal DataCapsule Weave(List <double> factors)
        {
            List <Complex> result = new List <Complex>();

            for (int i = 0; i < this.XValues.Count + factors.Count - 1; i++)
            {
                Complex sum = Complex.Zero;
                for (int j = 0; j < this.YValues.Count; j++)
                {
                    if (i - j < 0 || i - j >= factors.Count)
                    {
                        continue;
                    }
                    else
                    {
                        sum += this.YValues[j] * factors[i - j];
                    }
                }
                result.Add(sum);
            }

            List <double> xs = SignalLogics.GetTimeValues(this.XValues[this.XValues.Count - 1] / result.Count, this.XValues[this.XValues.Count - 1]).ToList();

            return(new DataCapsule(xs, result));
        }
Beispiel #3
0
        public void Generate()
        {
            ChartValues <ObservablePoint> here = new ChartValues <ObservablePoint>(), here1 = new ChartValues <ObservablePoint>();

            if (selectedSignal < 9)
            {
                NormalChartSeries[0] = new LineSeries
                {
                    Title         = "Sygnały przedstawiane liniowo",
                    PointGeometry = DefaultGeometries.Circle,
                    Fill          = Brushes.Transparent
                };
            }
            else
            {
                NormalChartSeries[0] = new ScatterSeries
                {
                    Title           = "Sygnały przedstawiane punktowo",
                    PointGeometry   = DefaultGeometries.Circle,
                    StrokeThickness = 2
                };
            }

            switch (SelectedSignal)
            {
            case 0:
                NormalChartSeries[0].Values   = model.GetUniformDistributionNoise(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), MinimumTextBox.GetValue(), MaximumTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetUniformDistributionNoise(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), MinimumTextBox.GetValue(), MaximumTextBox.GetValue());
                here  = (ChartValues <ObservablePoint>)model.GetUniformDistributionNoise(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), MinimumTextBox.GetValue(), MaximumTextBox.GetValue());
                here1 = (ChartValues <ObservablePoint>)model.GetUniformDistributionNoise(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), MinimumTextBox.GetValue(), MaximumTextBox.GetValue());
                break;

            case 1:
                NormalChartSeries[0].Values   = model.GetGaussianNoise(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), MeanTextBox.GetValue(), DeviationTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetGaussianNoise(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), MeanTextBox.GetValue(), DeviationTextBox.GetValue());
                here  = (ChartValues <ObservablePoint>)model.GetGaussianNoise(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), MeanTextBox.GetValue(), DeviationTextBox.GetValue());
                here1 = (ChartValues <ObservablePoint>)model.GetGaussianNoise(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), MeanTextBox.GetValue(), DeviationTextBox.GetValue());
                break;

            case 2:
                NormalChartSeries[0].Values   = model.GetSinSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetSinSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                here  = (ChartValues <ObservablePoint>)model.GetSinSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                here1 = (ChartValues <ObservablePoint>)model.GetSinSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                break;

            case 3:
                NormalChartSeries[0].Values   = model.GetSinAbsSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetSinAbsSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                here  = (ChartValues <ObservablePoint>)model.GetSinAbsSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                here1 = (ChartValues <ObservablePoint>)model.GetSinAbsSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                break;

            case 4:
                NormalChartSeries[0].Values   = model.GetSinDoubleAbsSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetSinDoubleAbsSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetSinDoubleAbsSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), FrequencyTextBox.GetValue(), StartTimetextBox.GetValue());
                break;

            case 5:
                NormalChartSeries[0].Values   = model.GetRectangularSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetRectangularSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetRectangularSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                break;

            case 6:
                NormalChartSeries[0].Values   = model.GetSymmetricRectangularSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetSymmetricRectangularSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetSymmetricRectangularSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                break;

            case 7:
                NormalChartSeries[0].Values   = model.GetTriangularSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetTriangularSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetTriangularSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), PeriodTextBox.GetValue(), StartTimetextBox.GetValue(), DutyCycleTextBox.GetValue());
                break;

            case 8:
                NormalChartSeries[0].Values   = model.GetJumpSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetJumpSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetJumpSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                break;

            case 9:
                NormalChartSeries[0].Values   = model.GetSingleImpulseSignal(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetSingleImpulseSignal(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetSingleImpulseSignal(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), JumpTimeTextBox.GetValue(), StartTimetextBox.GetValue());
                break;

            case 10:
                NormalChartSeries[0].Values   = model.GetImpulseNoise(SignalFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), ImpulseProbabilityTextBox.GetValue());
                SamplingChartSeries[0].Values = model.GetImpulseNoise(SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), ImpulseProbabilityTextBox.GetValue());
                here = (ChartValues <ObservablePoint>)model.GetImpulseNoise(ReconstructionFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), AmplitudeTextBox.GetValue(), ImpulseProbabilityTextBox.GetValue());
                break;
            }

            if (SelectedSignal >= 9)
            {
                HistogramLabels = SignalLogics.GetHistogramLabels((ChartValues <ObservablePoint>)NormalChartSeries[0].Values);
                HistogramChartSeries[0].Values = model.GetHistogram((ChartValues <ObservablePoint>)NormalChartSeries[0].Values);
            }
            else
            {
                HistogramLabels = SignalLogics.GetHistogramLabels((ChartValues <ObservablePoint>)NormalChartSeries[0].Values);
                HistogramChartSeries[0].Values = model.GetHistogram((ChartValues <ObservablePoint>)NormalChartSeries[0].Values);
            }

            QuantChartSeries[0].Values = model.GetQuant((ChartValues <ObservablePoint>)SamplingChartSeries[0].Values, QuantLevelAmountTextBox.GetValue());
            QuantChartSeries[1].Values = (ChartValues <ObservablePoint>)NormalChartSeries[0].Values;

            ZeroHoldChartSeries[0].Values = (ChartValues <ObservablePoint>)SamplingChartSeries[0].Values;
            ZeroHoldChartSeries[1].Values = (ChartValues <ObservablePoint>)NormalChartSeries[0].Values;

            SincReconstructionChartSeries[0].Values = model.GetSincReconstruction(ReconstructionFrequencyTextBox.GetValue(), SamplingFrequencyTextBox.GetValue(), TimeDurationTextBox.GetValue(), (ChartValues <ObservablePoint>)SamplingChartSeries[0].Values, SeenSamplesTextBox.GetValue());
            SincReconstructionChartSeries[1].Values = (ChartValues <ObservablePoint>)NormalChartSeries[0].Values;

            AverageTextBox.Text        = ResultLogics.GetAverage((ChartValues <ObservablePoint>)NormalChartSeries[0].Values).ToString();
            AbsAverageTextBox.Text     = ResultLogics.GetAbsAverage((ChartValues <ObservablePoint>)NormalChartSeries[0].Values).ToString();
            VariationTextBox.Text      = ResultLogics.GetVariation((ChartValues <ObservablePoint>)NormalChartSeries[0].Values).ToString();
            AveragePowerTextBox.Text   = ResultLogics.GetAveragePower((ChartValues <ObservablePoint>)NormalChartSeries[0].Values).ToString();
            RootMeanSquareTextBox.Text = ResultLogics.GetRootMeanSquare((ChartValues <ObservablePoint>)NormalChartSeries[0].Values).ToString();

            MeanSquareErrorTextBox.Text = ResultLogics.GetMeanSquareError((ChartValues <ObservablePoint>)SincReconstructionChartSeries[0].Values, here).ToString();

            //DLA KWANTY
            RatioTextBox.Text    = ResultLogics.GetRatio((ChartValues <ObservablePoint>)QuantChartSeries[0].Values, (ChartValues <ObservablePoint>)SamplingChartSeries[0].Values).ToString();
            MaxRatioTextBox.Text = ResultLogics.GetMaxRatio((ChartValues <ObservablePoint>)QuantChartSeries[0].Values, (ChartValues <ObservablePoint>)SamplingChartSeries[0].Values).ToString();

            MaxDiffrenceTextBox.Text = ResultLogics.GetMaxDiffrence((ChartValues <ObservablePoint>)SincReconstructionChartSeries[0].Values, here).ToString();
        }