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); }
public DoubleSeries GetClusteredPoints(double xCentre, double yCentre, double deviation, int count) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < count; i++) { double x = GetGaussianRandomNumber(xCentre, deviation); double y = GetGaussianRandomNumber(yCentre, deviation); doubleSeries.Add(new XYPoint() { X = x, Y = y }); } return(doubleSeries); }
public DoubleSeries GetStraightLine(double gradient, double yIntercept, int pointCount) { var doubleSeries = new DoubleSeries(pointCount); for (int i = 0; i <= pointCount; i++) { double x = i + 1; double y = gradient * x + yIntercept; doubleSeries.Add(new XYPoint() { X = x, Y = y }); } return(doubleSeries); }
public DoubleSeries GetRandomDoubleSeries(int pointCount) { var doubleSeries = new DoubleSeries(); double amplitude = _random.NextDouble() + 0.5; double freq = Math.PI * (_random.NextDouble() + 0.5) * 10; double offset = _random.NextDouble() - 0.5; for (int i = 0; i < pointCount; i++) { doubleSeries.Add(new XYPoint() { X = i, Y = offset + amplitude * Math.Sin(freq * i) }); } return(doubleSeries); }
public DoubleSeries GetLissajousCurve(double alpha, double beta, double delta, int count = 200) { // From http://en.wikipedia.org/wiki/Lissajous_curve // x = Asin(at + d), y = Bsin(bt) var doubleSeries = new DoubleSeries(count); for (int i = 0; i < count; i++) { double x = Math.Sin(alpha * i * 0.1 + delta); double y = Math.Sin(beta * i * 0.1); doubleSeries.Add(new XYPoint() { X = x, Y = y }); } return(doubleSeries); }
public DoubleSeries GetExponentialCurve(double power, int pointCount) { var doubleSeries = new DoubleSeries(pointCount); double x = 0.00001; const double fudgeFactor = 1.4; for (int i = 0; i < pointCount; i++) { x *= fudgeFactor; double y = Math.Pow((double)i + 1, power); doubleSeries.Add(new XYPoint() { X = x, Y = y }); } return(doubleSeries); }
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); }
public DoubleSeries GenerateSpiral(double xCentre, double yCentre, double maxRadius, int count) { var doubleSeries = new DoubleSeries(); double radius = 0; double x, y; double deltaRadius = maxRadius / count; for (int i = 0; i < count; i++) { double sinX = Math.Sin(2 * Math.PI * i * 0.05); double cosX = Math.Cos(2 * Math.PI * i * 0.05); x = xCentre + radius * sinX; y = yCentre + radius * cosX; doubleSeries.Add(new XYPoint() { X = x, Y = y }); radius += deltaRadius; } return(doubleSeries); }
public DoubleSeries GetButterflyCurve(int count = 2000) { // From http://en.wikipedia.org/wiki/Butterfly_curve_%28transcendental%29 // x = sin(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12)) // y = cos(t) * (e^cos(t) - 2cos(4t) - sin^5(t/12)) var temp = 0.01; var doubleSeries = new DoubleSeries(count); for (int i = 0; i < count; i++) { var t = i * temp; double multiplier = Math.Pow(Math.E, Math.Cos(t)) - 2 * Math.Cos(4 * t) - Math.Pow(Math.Sin(t / 12), 5); double x = Math.Sin(t) * multiplier; double y = Math.Cos(t) * multiplier; doubleSeries.Add(new XYPoint { X = x, Y = y }); } return(doubleSeries); }
public DoubleSeries GenerateEEG(int count, ref double startPhase, double phaseStep) { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); var time = i / (double)count; xyPoint.X = time; //double mod = 0.2 * Math.Sin(startPhase); xyPoint.Y = //mod * Math.Sin(startPhase / 4.9) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); startPhase += phaseStep; } return(doubleSeries); }
public DoubleSeries GetSquirlyWave() { var doubleSeries = new DoubleSeries(); var rand = new Random((int)DateTime.Now.Ticks); const int COUNT = 1000; for (int i = 0; i < COUNT; i++) { var xyPoint = new XYPoint(); var time = i / (double)COUNT; xyPoint.X = time; xyPoint.Y = time * Math.Sin(2 * Math.PI * i / (double)COUNT) + 0.2 * Math.Sin(2 * Math.PI * i / (COUNT / 7.9)) + 0.05 * (rand.NextDouble() - 0.5) + 1.0; doubleSeries.Add(xyPoint); } return(doubleSeries); }
public DoubleSeries GetFourierSeriesZoomed(double amplitude, double phaseShift, double xStart, double xEnd, int count = 5000) { var data = GetFourierSeries(amplitude, phaseShift, count); int index0 = 0; int index1 = 0; for (int i = 0; i < count; i++) { if (data.XData[i] > xStart && index0 == 0) { index0 = i; } if (data.XData[i] > xEnd && index1 == 0) { index1 = i; break; } } var result = new DoubleSeries(); var xData = data.XData.Skip(index0).Take(index1 - index0).ToArray(); var yData = data.YData.Skip(index0).Take(index1 - index0).ToArray(); for (int i = 0; i < xData.Length; i++) { result.Add(new XYPoint() { X = xData[i], Y = yData[i] }); } return(result); }
public DoubleSeries GetFourierSeries(double amplitude, double phaseShift, int count = 5000) { var doubleSeries = new DoubleSeries(); for (int i = 0; i < count; i++) { var xyPoint = new XYPoint(); double time = 10 * i / (double)count; double wn = 2 * Math.PI / (count / 10); xyPoint.X = time; xyPoint.Y = Math.PI * amplitude * (Math.Sin(i * wn + phaseShift) + 0.33 * Math.Sin(i * 3 * wn + phaseShift) + 0.20 * Math.Sin(i * 5 * wn + phaseShift) + 0.14 * Math.Sin(i * 7 * wn + phaseShift) + 0.11 * Math.Sin(i * 9 * wn + phaseShift) + 0.09 * Math.Sin(i * 11 * wn + phaseShift)); doubleSeries.Add(xyPoint); } return(doubleSeries); }
public DoubleSeries GetAcousticChannel(int channelNumber) { if (channelNumber > 7) { throw new InvalidOperationException("Only channels 0-7 allowed"); } if (_acousticPlotData.Count != 0) { return(_acousticPlotData[channelNumber]); } // e.g. resource format: Abt.Controls.SciChart.Example.Resources.EURUSD_Daily.csv var csvResource = string.Format("{0}.{1}", ResourceDirectory, "AcousticPlots.csv"); var ch0 = new DoubleSeries(100000); var ch1 = new DoubleSeries(100000); var ch2 = new DoubleSeries(100000); var ch3 = new DoubleSeries(100000); var ch4 = new DoubleSeries(100000); var ch5 = new DoubleSeries(100000); var ch6 = new DoubleSeries(100000); var ch7 = new DoubleSeries(100000); var assembly = typeof(DataManager).Assembly; using (var stream = assembly.GetManifestResourceStream(csvResource)) using (var streamReader = new StreamReader(stream)) { string line = streamReader.ReadLine(); line = streamReader.ReadLine(); while (line != null) { // Line Format: // Date, Open, High, Low, Close, Volume // 2007.07.02 03:30, 1.35310, 1.35310, 1.35280, 1.35310, 12 var tokens = line.Split(','); double x = double.Parse(tokens[0], NumberFormatInfo.InvariantInfo); double y0 = double.Parse(tokens[1], NumberFormatInfo.InvariantInfo); double y1 = double.Parse(tokens[2], NumberFormatInfo.InvariantInfo); double y2 = double.Parse(tokens[3], NumberFormatInfo.InvariantInfo); double y3 = double.Parse(tokens[4], NumberFormatInfo.InvariantInfo); double y4 = double.Parse(tokens[5], NumberFormatInfo.InvariantInfo); double y5 = double.Parse(tokens[6], NumberFormatInfo.InvariantInfo); double y6 = double.Parse(tokens[7], NumberFormatInfo.InvariantInfo); double y7 = double.Parse(tokens[8], NumberFormatInfo.InvariantInfo); ch0.Add(new XYPoint() { X = x, Y = y0 }); ch1.Add(new XYPoint() { X = x, Y = y1 }); ch2.Add(new XYPoint() { X = x, Y = y2 }); ch3.Add(new XYPoint() { X = x, Y = y3 }); ch4.Add(new XYPoint() { X = x, Y = y4 }); ch5.Add(new XYPoint() { X = x, Y = y5 }); ch6.Add(new XYPoint() { X = x, Y = y6 }); ch7.Add(new XYPoint() { X = x, Y = y7 }); line = streamReader.ReadLine(); } } _acousticPlotData.AddRange(new[] { ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7 }); return(_acousticPlotData[channelNumber]); }