Esempio n. 1
0
        public DoubleSeries GetDampedSinewave(int pad, double amplitude, double phase, double dampingFactor, int pointCount, int freq = 10)
        {
            var doubleSeries = new DoubleSeries();

            for (int i = 0; i < pad; i++)
            {
                double time = 10 * i / (double)pointCount;
                doubleSeries.Add(new XYPoint()
                {
                    X = time
                });
            }

            for (int i = pad, j = 0; i < pointCount; i++, j++)
            {
                var xyPoint = new XYPoint();

                double time = 10 * i / (double)pointCount;
                double wn   = 2 * Math.PI / (pointCount / (double)freq);

                xyPoint.X = time;
                xyPoint.Y = amplitude * Math.Sin(j * wn + phase);
                doubleSeries.Add(xyPoint);

                amplitude *= (1.0 - dampingFactor);
            }

            return(doubleSeries);
        }
Esempio n. 2
0
        public DoubleSeries GetRandomWalkSeries(int count)
        {
            var doubleSeries = new DoubleSeries(count);

            // Generate a slightly positive biased random walk
            // y[i] = y[i-1] + random,
            // where random is in the range -0.5, +0.5
            for (int i = 0; i < count; i++)
            {
                double next = _last + (_random.NextDouble() - 0.5 + _bias);
                _last = next;

                doubleSeries.Add(new XYPoint()
                {
                    X = _i++, Y = next
                });
            }

            return(doubleSeries);
        }