Exemple #1
0
        public double Process(ISGTimeDiscreteSignalSource <Point <int>, PointDouble, double> source)
        {
            double vola = 0;

            double average = 0;

            for (int i = 0; i < NumStepsBack; i++)
            {
                int    indexInner    = LastValueIndex - NumStepsBack + i;
                double valAtPosInner = source.ValueAt(new Point <int>(1)
                {
                    Values = new[] { indexInner }
                }).Values[0];
                average += valAtPosInner;
            }

            average = average / (NumStepsBack - 1);

            for (int i = 0; i < NumStepsBack; i++)
            {
                int    index    = LastValueIndex - NumStepsBack + i;
                double valAtPos = source.ValueAt(new Point <int>(1)
                {
                    Values = new[] { index }
                }).Values[0];

                vola += (valAtPos - average) * (valAtPos - average);
            }

            return(vola / (NumStepsBack - 1));
        }
Exemple #2
0
        public PointDouble ValueAt(Point <int> position)
        {
            PointDouble valueAtPos = _inputSignal.ValueAt(position);
            var         derivative = new PointDouble(position.Dimensions);

            for (int i = 0; i < position.Values.Length; i++)
            {
                var posP1Arr = new int[valueAtPos.Dimensions];
                Array.Copy(position.Values, posP1Arr, valueAtPos.Values.Length);
                posP1Arr[i] += 1;

                PointDouble posPlus1 = _inputSignal.ValueAt(new Point <int>(valueAtPos.Dimensions)
                {
                    Values = posP1Arr
                });

                //Calculate Forward Derivative in Direction i
                derivative = posPlus1 - valueAtPos;
            }

            return(derivative);
        }
Exemple #3
0
        private double TransformAt(int pos, ISGTimeDiscreteSignalSource <Point1DDiscrete, PointContinous1D, double> source)
        {
            double real = 0;
            double img  = 0;

            for (int i = 0; i < SignalLength; i++)
            {
                double valAtI = source.ValueAt(new Point1DDiscrete(i)).X;
                real += valAtI * Math.Cos(2 * Math.PI * i * pos / SignalLength);
                img  -= valAtI * Math.Sin(2 * Math.PI * i * pos / SignalLength);
            }

            return(real * real + img * img);
        }