Example #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));
        }
Example #2
0
        public SG1DTimeDiscreteValueContinousSignalSource Process(ISGTimeDiscreteSignalSource <Point1DDiscrete, PointContinous1D, double> source)
        {
            var output = new SG1DTimeDiscreteValueContinousSignalSource();

            for (int i = 0; i < SignalLength; i++)
            {
                output.PointContinous1Ds.Add(new PointContinous1D(TransformAt(i, source)));
            }

            return(output);
        }
Example #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);
        }
Example #4
0
 public double GetVola(ISGTimeDiscreteSignalSource <Point <int>, PointDouble, double> source, double deltaTime)
 {
     return(Math.Sqrt(Process(source) / deltaTime) / NumStepsBack);
 }
Example #5
0
 public double GetVariance(ISGTimeDiscreteSignalSource <Point <int>, PointDouble, double> source)
 {
     return(Process(source) / NumStepsBack);
 }
Example #6
0
 public SGDForwarderivativeProcessor(ISGTimeDiscreteSignalSource <Point <int>, PointDouble, double> input)
 {
     _inputSignal = input;
 }