Exemple #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));
        }
Exemple #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));
        }