Class Generate
- Namespace
- ScottPlot
- Assembly
- ScottPlot.dll
This class contains methods which generate sample data for testing and demonstration purposes
public static class Generate
- Inheritance
-
Generate
- Inherited Members
Fields
RandomWalker
public static readonly RandomWalker RandomWalker
Field Value
Properties
Financial
public static FinancialDataGenerator Financial { get; }
Property Value
RandomData
public static RandomDataGenerator RandomData { get; }
Property Value
Methods
AddNoise(double[], double)
Return a copy of the given array with random values added to each point
public static double[] AddNoise(double[] input, double magnitude = 1)
Parameters
Returns
- double[]
AddNoiseInPlace(double[], double)
Mutate the given array by adding a random value to each point
public static void AddNoiseInPlace(double[] values, double magnitude = 1)
Parameters
AddSin(double[], double, double, double, double)
Return a new array containing the given one plus a sine wave with the given parameters
public static double[] AddSin(double[] values, double mult = 1, double offset = 0, double oscillations = 1, double phase = 0)
Parameters
Returns
- double[]
AddSinInPlace(double[], double, double, double, double)
Modify the array to add a sine wave with the given parameters
public static double[] AddSinInPlace(double[] values, double mult = 1, double offset = 0, double oscillations = 1, double phase = 0)
Parameters
Returns
- double[]
Consecutive(int, DateTime, TimeSpan)
public static DateTime[] Consecutive(int count, DateTime start, TimeSpan timeSpan)
Parameters
Returns
- DateTime[]
Consecutive(int, DateTimeOffset, TimeSpan)
public static DateTimeOffset[] Consecutive(int count, DateTimeOffset start, TimeSpan timeSpan)
Parameters
count
intstart
DateTimeOffsettimeSpan
TimeSpan
Returns
Consecutive(int, double, double)
Return an array of evenly-spaced numbers
public static double[] Consecutive(int count = 51, double delta = 1, double first = 0)
Parameters
Returns
- double[]
Consecutive2D(int, int, double, double)
Generates a 2D array of numbers with constant spacing.
public static double[,] Consecutive2D(int rows, int columns, double spacing = 1, double offset = 0)
Parameters
Returns
- double[,]
ConsecutiveDateTimes(int, DateTime, TimeSpan)
public static DateTime[] ConsecutiveDateTimes(int count, DateTime start, TimeSpan timeSpan)
Parameters
Returns
- DateTime[]
ConsecutiveDateTimes(int, DateTimeOffset, TimeSpan)
public static DateTimeOffset[] ConsecutiveDateTimes(int count, DateTimeOffset start, TimeSpan timeSpan)
Parameters
count
intstart
DateTimeOffsettimeSpan
TimeSpan
Returns
ConsecutiveDays(int, DateTime)
public static DateTime[] ConsecutiveDays(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveDays(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveDays(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveDays(int, int, int, int)
public static DateTime[] ConsecutiveDays(int count, int year = 2023, int month = 1, int day = 1)
Parameters
Returns
- DateTime[]
ConsecutiveHours(int)
public static DateTime[] ConsecutiveHours(int count)
Parameters
count
int
Returns
- DateTime[]
ConsecutiveHours(int, DateTime)
public static DateTime[] ConsecutiveHours(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveHours(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveHours(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveMinutes(int, DateTime)
public static DateTime[] ConsecutiveMinutes(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveMinutes(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveMinutes(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveQuarterHours(int, DateTime)
public static DateTime[] ConsecutiveQuarterHours(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveQuarterHours(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveQuarterHours(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveSeconds(int, DateTime)
public static DateTime[] ConsecutiveSeconds(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveSeconds(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveSeconds(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveWeekdays(int, DateTime)
public static DateTime[] ConsecutiveWeekdays(int count, DateTime start)
Parameters
Returns
- DateTime[]
ConsecutiveWeekdays(int, DateTimeOffset)
public static DateTimeOffset[] ConsecutiveWeekdays(int count, DateTimeOffset start)
Parameters
count
intstart
DateTimeOffset
Returns
ConsecutiveWeekdays(int, int, int, int)
public static DateTime[] ConsecutiveWeekdays(int count, int year = 2023, int month = 1, int day = 1)
Parameters
Returns
- DateTime[]
Cos(int, double, double, double, double)
Return an array of cosine waves between -1 and 1.
Values are multiplied by mult
then shifted by offset
.
Phase shifts the sine wave horizontally between 0 and 2 Pi.
public static double[] Cos(int count = 51, double mult = 1, double offset = 0, double oscillations = 1, double phase = 0)
Parameters
Returns
- double[]
NaN(int)
public static double[] NaN(int count)
Parameters
count
int
Returns
- double[]
NoisyExponential(int, double, double, double)
An exponential curve that rises from 0 to mult
over count
points with random positive noise that scales
with the underlying signal. The rate constant of the exponential
curve is tau
.
public static double[] NoisyExponential(int count, double mult = 1000, double noise = 0.5, double tau = 5)
Parameters
Returns
- double[]
NoisySin(int, double)
[Obsolete("use Generate.Sin() then Generate.AddNoise()")]
public static double[] NoisySin(int count = 51, double magnitude = 1)
Parameters
Returns
- double[]
Ones(int)
public static double[] Ones(int count)
Parameters
count
int
Returns
- double[]
Ramp2D(int, int, double, double)
Generate a 2D array in a diagonal gradient pattern
public static double[,] Ramp2D(int width, int height, double min = 0, double max = 1)
Parameters
Returns
- double[,]
Random(int, double, double)
[Obsolete("use RandomSample()")]
public static double[] Random(int count, double min = 0, double max = 1)
Parameters
Returns
- double[]
RandomAscending(int, double, double)
Sequence of ascending numbers with random spacing between values.
public static double[] RandomAscending(int count, double minDelta = 0, double maxDelta = 1)
Parameters
Returns
- double[]
RandomBox(double)
public static Box RandomBox(double position)
Parameters
position
double
Returns
RandomChar()
public static char RandomChar()
Returns
RandomColor()
public static Color RandomColor()
Returns
RandomColor(IColormap)
public static Color RandomColor(IColormap colormap)
Parameters
colormap
IColormap
Returns
RandomColor(byte)
Generate a dark color by defining the maximum value to use for R, G, and B
public static Color RandomColor(byte max)
Parameters
max
byte
Returns
RandomColors(int, IColormap)
public static Color[] RandomColors(int count, IColormap colormap)
Parameters
Returns
- Color[]
RandomCoordinates(double, double, double, double)
public static Coordinates RandomCoordinates(double xMult = 1, double yMult = 1, double xOffset = 0, double yOffset = 0)
Parameters
Returns
RandomCoordinates(int, double, double, double, double)
public static Coordinates[] RandomCoordinates(int count, double xMult = 1, double yMult = 1, double xOffset = 0, double yOffset = 0)
Parameters
Returns
RandomHue()
public static Color RandomHue()
Returns
RandomInteger(int)
RandomSample integer between zero (inclusive) and max
(exclusive)
public static int RandomInteger(int max)
Parameters
max
int
Returns
RandomInteger(int, int)
RandomSample integer between min
(inclusive) and max
(exclusive)
public static int RandomInteger(int min, int max)
Parameters
Returns
RandomIntegers(int, int)
RandomSample integers between zero (inclusive) and max
(exclusive)
public static int[] RandomIntegers(int count, int max)
Parameters
Returns
- int[]
RandomIntegers(int, int, int)
RandomSample integers between min
(inclusive) and max
(exclusive)
public static int[] RandomIntegers(int count, int min, int max)
Parameters
Returns
- int[]
RandomLine()
public static CoordinateLine RandomLine()
Returns
RandomLinePattern()
public static LinePattern RandomLinePattern()
Returns
RandomLocation()
public static Coordinates RandomLocation()
Returns
RandomLocation(AxisLimits)
public static Coordinates RandomLocation(AxisLimits limits)
Parameters
limits
AxisLimits
Returns
RandomLocations(int)
public static Coordinates[] RandomLocations(int count)
Parameters
count
int
Returns
RandomLocations(int, AxisLimits)
public static Coordinates[] RandomLocations(int count, AxisLimits limits)
Parameters
count
intlimits
AxisLimits
Returns
RandomMarkerShape()
public static MarkerShape RandomMarkerShape()
Returns
RandomNormal(int, double, double)
public static double[] RandomNormal(int count, double mean = 0, double stdDev = 1)
Parameters
Returns
- double[]
RandomNormalNumber(double, double)
Return a number normally distributed around the given mean
according to the stdDev
standard deviation.
public static double RandomNormalNumber(double mean = 0, double stdDev = 1)
Parameters
Returns
RandomNumber()
RandomSample integer between 0 (inclusive) and 1 (exclusive)
public static double RandomNumber()
Returns
RandomNumber(double)
RandomSample integer between 0 (inclusive) and max
(exclusive)
public static double RandomNumber(double max)
Parameters
max
double
Returns
RandomNumber(double, double)
RandomSample integer between min
(inclusive) and max
(exclusive)
public static double RandomNumber(double min, double max)
Parameters
Returns
RandomNumbers(int, double)
Random numbers between zero (inclusive) and max
(exclusive)
public static double[] RandomNumbers(int count, double max)
Parameters
Returns
- double[]
RandomNumbers(int, double, double)
Random numbers between min
(inclusive) and max
(exclusive)
public static double[] RandomNumbers(int count, double min, double max)
Parameters
Returns
- double[]
RandomOHLC()
public static OHLC RandomOHLC()
Returns
RandomOHLC(DateTime)
public static OHLC RandomOHLC(DateTime date)
Parameters
date
DateTime
Returns
RandomOHLCs(int)
public static List<OHLC> RandomOHLCs(int count)
Parameters
count
int
Returns
RandomOHLCs(int, DateTime)
public static List<OHLC> RandomOHLCs(int count, DateTime startDate)
Parameters
Returns
RandomSample(int, double, double)
Return an array of count
random values
from min
to max
public static double[] RandomSample(int count, double min = 0, double max = 1)
Parameters
Returns
- double[]
RandomString(int)
public static string RandomString(int length)
Parameters
length
int
Returns
RandomWalk(int, double, double)
Return a series of values starting with offset
and
each randomly deviating from the previous by at most mult
.
public static double[] RandomWalk(int count, double mult = 1, double offset = 0)
Parameters
Returns
- double[]
Range(double, double, double)
Return values from start
to stop
(inclusive) separated by step
public static double[] Range(double start, double stop, double step = 1)
Parameters
Returns
- double[]
RangeWithCount(double, double, int)
Return count
values from start
to stop
(inclusive)
public static double[] RangeWithCount(double start, double stop, int count)
Parameters
Returns
- double[]
RangeWithStep(double, double, double)
Return values from start
to stop
(inclusive) separated by step
public static double[] RangeWithStep(double start, double stop, double step = 1)
Parameters
Returns
- double[]
Repeating(int, double)
public static double[] Repeating(int count, double value)
Parameters
Returns
- double[]
SampleVectors(int, int, double)
public static RootedCoordinateVector[] SampleVectors(int columns = 10, int rows = 10, double oscillations = 1)
Parameters
Returns
Sigmoidal(int, double, double)
Return an array for a sigmoidal curve that rises from zero to mult
public static double[] Sigmoidal(int count, double mult = 1, double steepness = 1)
Parameters
Returns
- double[]
Sin(int, double, double, double, double)
Return an array of sine waves between -1 and 1.
Values are multiplied by mult
then shifted by offset
.
Phase shifts the sine wave horizontally between 0 and 2 Pi.
public static double[] Sin(int count = 51, double mult = 1, double offset = 0, double oscillations = 1, double phase = 0)
Parameters
Returns
- double[]
Sin2D(int, int, double, double, double)
Generates a 2D sine pattern.
public static double[,] Sin2D(int width, int height, double xPeriod = 0.2, double yPeriod = 0.2, double multiple = 100)
Parameters
width
intheight
intxPeriod
doubleFrequency factor in x direction.
yPeriod
doubleFrequency factor in y direction.
multiple
doubleIntensity factor.
Returns
- double[,]
SquareWave(uint, uint, double, double, double)
public static double[] SquareWave(uint cycles = 20, uint pointsPerCycle = 1000, double duty = 0.5, double low = 0, double high = 1)
Parameters
Returns
- double[]
SquareWaveFromSines(int, double, int)
Generate a square wave by summing sine waves with decreasing amplitudes at odd harmonics of the fundamental frequency
public static double[] SquareWaveFromSines(int pointCount = 1000, double oscillations = 2, int sineCount = 5)
Parameters
Returns
- double[]
Zeros(int)
public static double[] Zeros(int count)
Parameters
count
int
Returns
- double[]