Generate Data¶
The Generate Data option in the Edit menu and in the main toolbar is used to create data from a mathematical set of equations.
Entering the Function Expression¶
The function entry uses a simple ASCII multiline editor. The format is similar to that used for User-Defined Functions.
You can use the Cut, Copy, and Paste items to move text about or to paste in the formula if you placed it into the clipboard via another program.
All of the functions and constants available within TableCurve 2D can be accessed via a special Function Insert help.
You can define as many constants as you want. For example, SQRT2PI=SQRT(2*PI) would be defined on one line and used in subsequent lines. Constant expressions are evaluated once and the numeric result is stored. Any assignment to a variable other than F1-F25 and Y is assumed to be a constant. Any expression containing X or XYINDEX must be assigned either to an F1-F25 expression or to Y. F1-F25 and Y expressions are compiled and are evaluated once for each data point. The Y expression must always be the last line in the signal expression. The following is a simple signal example that generates one random sinusoid. There are five constants and a single Y= signal expression
SRATE=5000
NYQ=SRATE/2
AMP=50+50*RANDOM
FREQ=NYQ*(0.01+0.09*RANDOM)
PHASE=2*PI*RANDOM
Y=AMP*SIN(2*PI*X*FREQ+PHASE)
The following example generates three random sinusoids and uses F1-F3 functions.
SRATE=5000
NYQ=SRATE/2
AMP1=50+50*RANDOM
AMP2=50+50*RANDOM
AMP3=50+50*RANDOM
FREQ1=NYQ*(0.0166667+0.15*RANDOM)
FREQ2=NYQ*(0.1666667+0.1666667*RANDOM);
FREQ3=NYQ*(0.3333333+0.15*RANDOM);
PHASE1=2*PI*RANDOM
PHASE2=2*PI*RANDOM
PHASE3=2*PI*RANDOM
F1=AMP1*SIN(2*PI*X*FREQ1+PHASE1)
F2=AMP2*SIN(2*PI*X*FREQ2+PHASE2)
F3=AMP3*SIN(2*PI*X*FREQ3+PHASE3)
Y=F1+F2+F3
Using Derivative Functions¶
The first derivative function is DX(Fn) where n is from 1 to 25 and references an F1 to F25 expression. The second derivative function is DX2(Fn). The following example is for the first derivative of a sine function:
F1=100*SIN(2*PI*X*5000+PI/2)
Y=DX(F1)
Using Integration Functions¶
The primary integration function is AIP(n,start,end,prec). It first seeks to achieve the target precision using a successive step Gaussian Quadrature. If this is unsuccessful, a Romberg procedure follows. If the Romberg fails to achieve the desired precision, an Adaptive Quadrature procedure is used. The following example uses the AIP() function to generate the cumulative of the Log-Normal distribution:
LOWER=1E-8
F1=LN($/2.1)/5.2
F2=EXP(-0.5*F1*F1)
Y=100*AIP(F2,LOWER,X,1E-6)
Note that the $ symbol is used as the variable of integration. In this example, the second function expression is integrated with $ ranging from a lower limit to X, to a precision of 6 significant figures. Infinite limits are supported although you must use the -INF and INF constants in order to automatically trigger the transforms.
Gaussian Quadrature Functions¶
The Romberg and Adaptive Quadrature algorithms are generally much slower than the Gaussian Quadrature procedure. For numerically intense integrations, you may wish to restrict the integration to the Gaussian Quadrature procedure. This is done by using the QIP(n,start,end,prec) function.
Validation¶
An expression is extensively validated before it is compiled. If there is a math or parser error, you will be given a clear indication of the error and the cursor will be placed at the location where the validation failed.
Generated X Values¶
The X Minimum, X Increment, and X Maximum fields are used to create the X values that will be used for the generated signal. The output is limited to 65536 values.
Adding White Noise¶
To automatically add white noise to the generated data, enter a value in the Gaussian Noise % field. Gaussian noise with a standard deviation of this % of the data series standard deviation is added at the conclusion of the signal generation.
Saving a Signal¶
Files are saved as signals with SIG extensions. Use the Save button to save the generated data expression to disk. The expression is always validated before a save is made.
Reading a Signal¶
Use the Read button to read a SIG file from disk. These files are binary and must be created within the program.
TableCurve 2D Graph¶
When the expression is successfully validated, the generated data is plotted in a TableCurve 2D Graph.
The List Data option lists the index, x, y values of the generated data. The listing uses the TableCurve 2D text viewer facility.
The Copy Data to Clipboard option copies the x and y values of the generated data to the clipboard. Formats include full precision binary (for spreadsheets such as Excel) and ASCII (for pasting into text editors).
The Save Data to Disk option writes the x and y values of the generated data to a supported file format. These formats include ASCII, Excel 97/2000, Excel 95, Lotus WK3, Lotus WK1, SPSS, or Systat.
Close the graph with the OK button in order to be offered an option to update the main data table with the generated data.
Close the graph with the Cancel button to be returned to the expression entry dialog.