DataGraph
Print

Built-in Functions

DataGraph has over 70 built-in, or named, functions. Functions can be used anywhere in DataGraph that accepts numerical values. These built-in functions can be used to:

Examples

Function input can be numbers, variables, or column names.

Some functions accept multiple inputs (i.e., a list of numbers). For example, the sum function can accept multiple inputs with commas in between such that: sum(1,2,3) = 6.  

The List of Input functions is useful for row operations across multiple columns. For example, the row-by-row sum of three columns A, B, and C can be computed as sum(A, B, C).

The remaining functions have a specified number of input arguments. For example, the standard functions have one input and one output, sin(0.5) = 0.47943.  If a column with multiple entries is input, the output will be computed row-by-row.

Multiple Inputs

These functions act on a list of inputs of any length. You can input single numbers separated by commas, or enter a comma-separated list of column names. For example, if you have three columns named A, B, and C, you can sum the values in each row by entering, sum(A, B, C) in an Expression column.

minminimum of two or more arguments.  min(3,5) = 3, min(3,5,2) = 2.
maxmaximum of two or more arguments; max(3,5) = 5, max(3,5,2) = 5.
meanmean of two or more arguments; mean(3,5,2) = 3.3333.
medianmedian of two or more arguments; median(3,5,2) = 3.
sdsample standard deviation; sd(3,5,2) = 1.5275.
sumthe sum of two or more arguments; sum(3,5,2) = 10.
normnorm of a vector, norm(3,5) = sqrt(3^2 + 5^2), norm(3,5,1) = sqrt(3^2 + 5^2 + 1^2)

NOTE: If you need to perform similar calculations for all entries in a column (e.g., sum a column of numbers), use the column properties or create a number from column variables. The Pivot command can also perform calculations.

Standard Functions

Function input can be numbers, variables, or column names. When the input is a column with n row values, the function will output n results.

sinsin in radians
coscos in radians
tantan(x) = sin(x)/cos(x) in radians
asininverse of sin(x)
acosinverse of cos(x)
ataninverse of tan(x)
angleangle(x,y) = the angle that the line (0,0) to (x,y) makes with the positive x axis. The angle is in radians.  That means that angle(cos(x),sin(x)) = x for x from -π,π.  angle(-1,0) is π.  This is better than using the inverse of tan (atan) because it will deal with the sign properly. NOTE: This function is equivalent to atan2(y,x), used by some software.
sinhhyperbolic sin, sinh(x) = (exp(x)-exp(-x))/2
coshhyperbolic cos,   cosh(x) = (exp(x)+exp(-x))/2
tanhhyberbolic tan,   tanh(x) = sinh(x)/cosh(x)
sincsinc(x) = sin(x)/x when x≠0, and 1 when x==0.
sqrtsquare root of a number
cbrtcube root of a number
expexponent of a number, exp(x) = e^x.
lognatural logarithm, the inverse of exp(x)
log1plog1p(x) = log(1+x)
log10base 10 logarithm, inverse of 10^x
log2base 2 logarithm, inverse of 2^x
absabsolute value of a number, or the number without its sign.
sgnsgn(x) is the sign of x.  sgn(x) = -1 if x<0, sgn(0) = 0, and sgn(x) = 1 if x>0.

Integers & Rounding

floorfloor(x) is the largest integer value less than or equal to x.
floor(4.5) = 4
floor(-4.5) = -5;
ceilceil(x) is the smallest integer value greater than or equal to x.
ceil(4.5) = 5
ceil(-4.5) = -4;
roundround(x) rounds x to the nearest integer;
round(4.5) = 5, round(-4.5) = -5.
round(x,d) rounds a to a specified number of digits, d;
round(3.225,1) = 3.2.
Half points are rounded away from zero.
modRemainder after division. 
mod(9,4) = 1 because 9 = 4*2 + 1. 
Works also for fractions.
mod(9.2,0.5) = 0.2, because 9.2 = n*0.5 + 0.2 where n is 18.

Logical Functions

ifif(a,b,c)  where it returns b if a is non-zero and c if a is zero.  Example: if(x<3,valueIfTrue,valueIfFalse)
isfiniteisfinte(a) where it returns 1 when a is finite (number), where 0 when a is NaN.
isnanisnan(a) where it returns 1 when a is NaN (which stands for not a number), or returns 0 otherwise. Works for nan or NAN, not case sensitive.

Special Functions

gammathe Gamma function,  https://en.wikipedia.org/wiki/Gamma_function
loggammaloggamma(x) = log(gamma(x)), needed because the gamma function increases rapidly
factFactorial of the number.  Returns NAN if the argument is not an integer.  Note that fact(n) = gamma(n+1), so far large values you can compute log(fact(n)) by using loggamma(n+1).  So if you want to compute n!/( (n-k)! * k!) when n is too large, you can use exp( loggamma(n+1) – loggamma(n-k+1) – loggamma(k+1))
erfError function, integral of exp(-t^2) from 0 to infinity, scaled so that the asymptotes at +/- ∞ are +/- 1. https://en.wikipedia.org/wiki/Error_function
erfcComplementary error function erfc(x) = 1.0-erf(x).  So erfc(x) is very close to 0 if x is large, and is more accurate than using 1.0-erf(x).
lambertwLambert W function also known as the product logarithm. Returns the principal branch of the function. https://en.wikipedia.org/wiki/Lambert_W_function
j0One of the Bessel functions – https://en.wikipedia.org/wiki/Bessel_function.  j0(x) = Bessel function of the first kind of order 0 of x.
j1Bessel function of the first kind of order 1.
jnjn(n,x) = Bessel function of the first kind of order n of x.
y0Bessel function of the second kind of order 0 of x.
y1Bessel function of the second kind of order 1 of x.
ynyn(n,x) = Bessel function of the second kind of order n of x.

Piecewise Functions

rectrect(x) = 1 if (|x|<0.5, 0.5 if x=+/- 0.5 and 0 if |x|>0.5
tritri(x) = 0 if |x|>1, tri(x) = 1-|x| if |x|≤1.
HH(x) = 0 if x<0, H(0) = 0.5, H(x) = 1 if x>0

Ternary Functions

The ternary functions calculate the relative amounts of three values and map them from a three-coordinate system (a,b,c) into the corresponding x and y locations in a cartesian coordinate system. One function provides the x location and another function provides the y location. The (x,y) output from the ternary functions can be used in any drawing commands (e.g., points, plot).

ternaryXternaryX(a,b,c) = x location in a ternary diagram centered at 0,0.
ternaryYternaryY(a,b,c) = y location in a ternary diagram centered at 0,0.

NOTE: The bottom left corner is the relative value of “a”, or where “a = 1”. The values for “a,b,c” move counterclockwise around the triangle. Place a negative in front of the functions to flip the triangle in the vertical direction.

Date & Time Functions

The Date column internally uses a Unix or POSIX time format (seconds since Jan 1st, 1970). The following functions allow you to create date columns, or manipulate existing date columns to pull various values from them (e.g., week, month, …) using an Expression column.

NOTE: Hour is from 0 to 24 (24 means the next day).

secondsCombine individual date/time values (from Number columns) to create a single proper date column. Examples:
seconds(year,month,day) – midnight at the start of a given day
seconds(year,month,day,hour,minute) – a specific day/time
seconds(year,month,day,hour,minute,seconds) – include seconds  
yearThe argument is a POSIX time, and what is returned is the year for that date
monthThe argument is a POSIX time, and what is returned is the month for that date
dayThe argument is a POSIX time, and what is returned is the day for that date
dayofweekThe argument is a POSIX time.  Returns 1 for a Monday, 7 for Sunday
dayofyear
The argument is a POSIX time, and what is returned is the day in that year, with Jan 1st equal to 1.
weekThe input is a POSIX time Week number – see https://en.wikipedia.org/wiki/ISO_week_date 
weekyear
Input is a POSIX time.  Computes the year for the week, to match with the week(x) functionality.
hourInput is a POSIX time, returns the hour
minuteInput is a POSIX time, returns the minute
secondInput is a POSIX time, returns the second.  Same as mod(x,60)
isAMInput is a POSIX time, returns 1 if the hour is <12, 0 otherwise.
isPMInput is a POSIX time, returns 1 if the hour is ≥12, 0 otherwise.

Statistical Functions

The functions for generating random numbers (rand and nrand) are only available in the Expression column. The other functions can be used in Expression columns or Expression variables.

tcdftcdf(x,df) the cumulative distribution function from the Student’s t distribution, at specified degrees of freedom (df)  
tpdftpdf(x,df) the probability density function (pdf) from the Student’s t distribution, at specified degrees of freedom (df)
tinv tinv(p,df) inverse of the cumulative distribution function from the Student’s t distribution, at specified probability (p) and degrees of freedom (df)
randrand(a,b) returns a random number between a and b
nrandreturns a random number sampled from a normal distribution. Examples: nrand(sd), mean of zero and standard deviation (sd) or nrand (x,sd) mean of x and standard deviation (sd).
On This Page