Functions

A growing list of functions that you can use in formulas and scripting...

abs (x) – absolute value
abs# (vector#) – absolute value of each element of vector#
abs## (matrix##) – absolute value of each cell of matrix##
appendFile (filePath$, ...) – write texts, numbers, vectors and so on at the end of an existing file (create such a file if it does not exist yet)
appendFileLine (filePath$, ...) – write texts, numbers, vectors and so on, followed by a newline, at the end of an existing file (create such a file if it does not exist yet)
arccos (x) – inverse cosine
arccos# (vector#) – inverse cosine of each element of vector#
arccos## (matrix##) – inverse cosine of each cell of matrix##
arccosh (x) – inverse hyperbolic cosine
arccosh# (vector#) – inverse hyperbolic cosine of each element of vector#
arccosh## (matrix##) – inverse hyperbolic cosine of each cell of matrix##
arcsin (x) – inverse sine
arcsin# (vector#) – inverse sine of each element of vector#
arcsin## (matrix##) – inverse sine of each cell of matrix##
arcsinh (x) – inverse hyperbolic sine
arcsinh# (vector#) – inverse hyperbolic sine of each element of vector#
arcsinh## (matrix##) – inverse hyperbolic sine of each cell of matrix##
arctan (x) – inverse tangent
arctan# (vector#) – inverse tangent of each element of vector#
arctan## (matrix##) – inverse tangent of each cell of matrix##
arctanh (x) – inverse hyperbolic tangent
arctanh# (vector#) – inverse hyperbolic tangent of each element of vector#
arctanh## (matrix##) – inverse hyperbolic tangent of each cell of matrix##
backslashTrigraphsToUnicode$ (string$) – convert e.g. \ct to ɔ
barkToHertz (x) – from Bark-rate to acoustic frequency
besselI (n, x) – modified Bessel function of the first kind, In
besselK (n, x) – modified Bessel function of the second kind, Kn
beta (x, y) – β function
between_by# (low, high, step) – symmetrically dispersed numbers between low and high, in steps of step
between_count# (low, high, n)n symmetrically dispersed numbers between low and high (bin centres)
binomialP (p, k, n) – probability of Bernoulli event occurring at most k in n times
binomialQ (p, k, n) – probability of Bernoulli event occurring at least k in n times
ceiling (x) – round up to integer
ceiling# (vector#) – round up each element of vector#
ceiling## (matrix##) – round up each cell of matrix##
center (v#) – center (or centre) of gravity
chiSquareP (chiSquare, df) – area under the χ2 curve up to chiSquare
chiSquareQ (chiSquare, df) – area under the χ2 curve after chiSquare
columnSums# (matrix##)
cos (x) – cosine
cos# (vector#) – cosine of each element of vector#
cos## (matrix##) – cosine of each cell of matrix##
cosh (x) – hyperbolic cosine
cosh# (vector#) – hyperbolic cosine of each element of vector#
cosh## (matrix##) – hyperbolic cosine of each cell of matrix##
createFolder (folderPath$) – create a new folder, or do nothing if it already exists
date$ ( ) – current local date and time in the form "Mon Nov 8 16:32:42 2021"
date# ( ) – current local date and time in the form { 2021, 11, 8, 16, 32, 42 }
date_utc$ ( ) – current standard date and time in the form "Mon Nov 8 15:32:42 2021"
date_utc# ( ) – current standard date and time in the form { 2021, 11, 8, 15, 32, 42 }
deleteFile (filePath$) – delete a file, or do nothing if it does not exist
differenceLimensToPhon (x) – from jnd-scale to perceptual loudness
endsWith (string$, part$) – determine whether string$ ends in part$
erb (f) – equivalent rectangular bandwidth for frequency f
erbToHertz (x) – from ERB-rate to acoustic frequency
erf (x) – error function, the integral of the Gaussian
erfc (x) – complement of the error function, i.e. 1 - erf (x); this is a separate function because erf (x) can be close to 1
exp (x) – exponentiation, i.e. ex
exp# (vector#) – exponentiate each element of vector#
exp## (matrix##) – exponentiate each cell of matrix##
extractLine$ (string$, part$) – everything that comes after the first occurrence of part$ in string$
extractNumber (string$, part$) – the first number after the first occurrence of part$ in string$
extractWord$ (string$, part$) – the first "word" after the first occurrence of part$ in string$
fileNames$# (folderNameOrPattern$) – get the names (not the whole paths) of the files in a folder or that match a pattern with an asterisk
fileReadable (filePath$) – 1 if the file exists and can be read, 0 otherwise
fisherP (f, df1, df2) – area under the Fisher F curve up to f
fisherQ (f, df1, df2) – area under the Fisher F curve after f
fixed$ (number, precision) – format a number as a string, with precision digits after the decimal point
floor (x) – round down to integer
floor# (vector#) – round down each element of vector#
floor## (matrix##) – round down each cell of matrix##
folderNames$# (folderNameOrPattern$) – get the names (not the whole paths) of the subfolders in a folder or that match a pattern with an asterisk
from_to# (m, n) – the integers from m through n
from_to_by# (m, n, step) – numbers from m through n, in steps of step
from_to_count# (start, end, n)n numbers from start through end
gaussP (z) – area under the normal curve up to z
gaussQ (z) – area under the normal curve after z
hertzToBark (x) – from acoustic frequency to Bark-rate
hertzToErb (x) – from acoustic frequency to ERB-rate
hertzToMel (x) – from acoustic frequency to mel
hertzToSemitones (x) – from acoustic frequency to logarithmic scale re 100 Hz
imax (x, ...) – location of the maximum
imin (x, ...) – location of the minimum
index (string$, part$) – look up a substring, or 0 if not found
index (strings$#, s$) – look up whether and where s$ first occurs in strings$#
index_regex (string$, regex$) – determine whether and where string$ first matches regex$
inner (a#, b#) – inner product
invBinomialP (P, k, n) – inverse of binomialP
invBinomialQ (Q, k, n) – inverse of binomialQ
invChiSquareQ (q, df) – inverse of chiSquareQ
invFisherQ (q, df1, df2) – inverse of fisherQ
invGaussQ (z) – inverse of gaussQ
invSigmoid (x) – inverse sigmoid
invStudentQ (q, df) – inverse studentQ
left$ (string$, n) – the n first characters in string$
length (string$) – number of Unicode characters in string$
ln (x) – natural logarithm, base e
ln# (vector#) – natural logarithm of each element of vector#
ln## (matrix##) – natural logarithm of each cell of matrix##
lnGamma (x) – logarithm of the Γ function
log2 (x) – logarithm, base 2
log2# (vector#) – base-2 logarithm of each element of vector#
log2## (matrix##) – base-2 logarithm of each cell of matrix##
log10 (x) – logarithm, base 10
log10# (vector#) – base-10 logarithm of each element of vector#
log10## (matrix##) – base-10 logarithm of each cell of matrix##
max (x, ...) – maximum
mean (v#) – average of the elements of a vector
melToHertz (x) – from mel to acoustic frequency
mid$ (string$, from, n) – the n characters in string$ starting at position from
min (x, ...) – minimum
mul## (a##, b##) – matrix multiplication
number (a$) – interpret a string as a number
numberOfColumns (matrix##)
numberOfRows (matrix##)
outer# (a#, b#) – outer product, i.e. resultij = aibj
percent$ (number, precision) – format a number as a string, with a trailing percent sign and precision digits after the decimal point
phonToDifferenceLimens (x) – from perceptual loudness to jnd-scale
randomBernoulli (p) – Bernoulli-distributed random deviate (0 or 1)
randomBernoulli# (n, p)n independent Bernoulli-distributed zeroes and ones
randomGamma (shape, rate) – gamma-distributed random deviate
randomGamma# (n, shape, rate)n independent gamma-distributed random numbers
randomGamma# (vector#, shape, rate) – duplicate vector#, and replace all elements with independent gamma-distributed random numbers
randomGamma## (nrow, ncol, shape, rate)nrow × ncol independent gamma-distributed random numbers
randomGamma# (matrix##, shape, rate) – duplicate matrix#, and replace all cells with independent gamma-distributed random numbers
randomGauss (μ, σ) – normally distributed random deviate
randomGauss# (n, μ, σ)n independent normally distributed random numbers
randomGauss# (vector#, μ, σ) – duplicate vector#, and replace all elements with independent normally distributed random numbers
randomGauss## (nrow, ncol, μ, σ)nrow × ncol independent normally distributed random numbers
randomGauss# (matrix##, μ, σ) – duplicate matrix#, and replace all cells with independent normally distributed random numbers
randomInteger (min, max) – uniformly distributed integer random deviate
randomInteger# (n, min, max)n independent uniformly distributed random integers
randomInteger# (vector#, min, max) – duplicate vector#, and replace all elements with independent uniformly distributed random integers
randomInteger## (nrow, ncol, min, max)nrow × ncol independent uniformly distributed random integers
randomPoisson (mean) – Poisson-distributed random deviate
randomPoisson# (n, mean)n independent Poisson-distributed random numbers
randomPoisson# (vector#, mean) – duplicate vector#, and replace all elements with independent Poisson-distributed random numbers
randomPoisson## (nrow, ncol, mean)nrow × ncol independent Poisson-distributed random numbers
randomPoisson# (matrix##, mean) – duplicate matrix#, and replace all cells with independent Poisson-distributed random numbers
randomUniform (min, max) – uniformly distributed random deviate
randomUniform# (n, min, max)n independent uniformly distributed random numbers
randomUniform# (vector#, min, max) – duplicate vector#, and replace all elements with independent uniformly distributed random numbers
randomUniform## (nrow, ncol, min, max)nrow × ncol independent uniformly distributed random numbers
randomUniform# (matrix##, min, max) – duplicate matrix#, and replace all cells with independent uniformly distributed random numbers
random_initializeSafelyAndUnpredictably ( ) – undoes the effects of the following function
random_initializeWithSeedUnsafelyButPredictably (seed) – reproducible sequence of random numbers
readFile (filePath$) – read a number from a text file
readFile$ (filePath$) – read a whole text file into a string
readLinesFromFile$# (filePath$) – read all lines from a text file
rectify (x) – set to zero if negative (no change if positive)
rectify# (vector#) – rectify each element of vector#
rectify## (matrix##) – rectify each cell of matrix##
repeat# (v#, n) – repeat the whole sequence of elements of v# n times
replace$ (a$, b$, c$, n) – within a$, replace the first n occurrences of b$ with c$, or all if n = 0
replace_regex$ (a$, b$, c$, n) – within a$, replace the first n matches of regular expression b$ with the regular expression c$, or all if n = 0
right$ (string$, n) – the n last characters in string$
rindex (string$, part$) – look up a substring from the end, or 0 if not found
rindex_regex (string$, regex$) – determine whether and where string$ last matches regex$
round (x) – nearest integer
round# (vector#) – nearest integer of each element of vector#
round## (matrix##) – nearest integer of each cell of matrix##
rowSums# (matrix##)
semitonesToHertz (x) – from logarithmic scale re 100 Hz to acoustic frequency
sigmoid (x) – 1 / (1 + e-x)
sin (x) – sine
sin# (vector#) – sine of each element of vector#
sin## (matrix##) – sine of each cell of matrix##
sinc (x) – sinus cardinalis: sin (x) / x
sincpi (x) – sin (πx) / (πx)
sinh (x) – hyperbolic sine
sinh# (vector#) – hyperbolic sine of each element of vector#
sinh## (matrix##) – hyperbolic sine of each cell of matrix##
size (v#) – number of elements
shuffle# (vector#) – randomize order
softmax# (vector#)
softmaxPerRow## (matrix##)
sort# (vector#) – reshuffle in increasing order
splitByWhitespace$# (string$) – split a string into inks
sqrt (x) – square root
sqrt# (vector#) – square root of each element of vector#
sqrt## (matrix##) – square root of each cell of matrix##
startsWith (string$, part$) – determine whether string$ starts with part$
stdev (v#) – standard deviation of the elements of a vector
stopwatch – give the current value of the timer, which is then immediately reset to zero (note: no parentheses)
string$ (number) – format a number as a string
studentP (t, df) – area under the Student T curve up to t
studentQ (t, df) – area under the Student T curve after t
sum (v#) – sum the elements
sumOver (loopVariable to n, numericExpressionOptionallyUsingLoopVariable) – Σ
tan (x) – tangent
tan# (vector#) – tangent of each element of vector#
tan## (matrix##) – tangent of each cell of matrix##
tanh (x) – hyperbolic tangent
tanh# (vector#) – hyperbolic tangent of each element of vector#
tanh## (matrix##) – hyperbolic tangent of each cell of matrix##
to# (n) – the integers 1 through n
transpose## (matrix##)
unicode (c$) – the Unicode codepoint number that corresponds to character c$
unicode$ (n) – the character that corresponds to Unicode codepoint n
unicodeToBackslashTrigraphs$ (string$) – convert e.g. ɔ to \ct
writeFile (filePath$, ...) – create a new text file, and write texts, numbers, vectors and so on into it
writeFileLine (filePath$, ...) – create a new text file, write texts, numbers, vectors and so on into it, followed by a newline
zero# (n) – vector with n elements that are all 0

© ppgb, November 18, 2021