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##
 appDay ( ) – the month day at which the present version of Praat was built
 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)
 appendInfo (...) – write texts, numbers, vectors and so on, to the Info window
 appendInfoLine (...) – write texts, numbers, vectors and so on, followed by a newline, to the Info window
 appMonth ( ) – the month in which the present version of Praat was built (between 1 and 12)
 appMonth$ ( ) – the name of the month (in English) in which the present version of Praat was built
 appVersion ( ) – the number of the present version of Praat
 appVersion$ ( ) – the present version of Praat, as text
 appYear ( ) – the year in which the present version of Praat was built
 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##
 arctan2 (y, x) – argument angle
 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##
 assert condition – condition checking
 asserterror message$ – testing that a certain error occurs
 asynchronous – let the script continue while the sound is playing
 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
 chooseFolder$ (title$) – pops up a folder selection window
 chooseReadFile$ (title$) – pops up a file selection window for opening (or appending to) an existing file
 chooseWriteFile$ (title$, defaultFilename$) – pops up a file selection window for saving to a new file
 clearinfo – clear the Info window
 col – the columns number (of the current cell) in a Formula command
 col$ [i] – the name of column i of an object
 col# (matrix##, columnNumber) - extract one column from a matrix
 columnSums# (matrix##)
 combine# (...) - combine numbers, vectors and matrices into a new vector
 correlation (u#, v#) – correlation (between −1 and +1) of two vectors
 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_iso$ ( ) – current local date and time in the form "2021-11-08T16:32:42+01:00"
 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_iso$ ( ) – current standard date and time in the form "2021-11-08T15:32:42Z"
 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
 demo – execute a graphics command in the Demo window (instead of in the Picture window)
 demoClicked ( ) – determine whether the user clicked in the Demo window
 demoClickedIn (xmin, xmax, ymmin, ymax) – determine whether the user clicked in a rectangular region in the Demo window
 demoCommandKeyPressed ( ) – determine whether the user pressed the Command key when they typed into the Demo window
 demoInput (characters$) – determine whether the user typed (or clicked) the specified characters into the Demo window
 demoKey$ ( ) – determine the key that the user typed into the Demo window
 demoKeyPressed ( ) – determine whether the user typed anything into the Demo window
 demoOptionKeyPressed ( ) – determine whether the user pressed the Option key when they typed into the Demo window
 demoPeekInput ( ) – see whether a user event (click or key press) is available in the Demo window
 demoShiftKeyPressed ( ) – determine whether the user pressed the Shift key when they typed into the Demo window
 demoShow ( ) – make all deferred drawing commands immediately visible
 demoWaitForInput ( ) – wait for a user event (click or key press) in the Demo window
 demoWindowTitle (newTitle$) – change the title of the Demo window
 demoX ( ) – the horizontal position of a mouse click in the Demo window
 demoY ( ) – the vertical position of a mouse click in the Demo window
 differenceLimensToPhon (x) – from jnd-scale to perceptual loudness
 dx – the horizontal distance between cells (i.e. the distance between columns) of an object
 dy – the vertical distance between cells (i.e. the distance between rows) of an object
 editor (editor($)) – enter the environment of an editor (by number or by name)
 empty$# (numberOfStrings) – create an array of empty strings
 endeditor – leave the environment of an editor
 endproc – end a procedure definition
 endsWith (string$, part$) – determine whether string$ ends in part$
 endsWith_caseInsensitive (string$, part$) – determine whether string$ ends in part$
 environment$ (string$) – look up a system environment string
 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
 exitScript (...) – show a message that tells the user why the script will be interrupted
 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
 fileNames_caseInsensitive$# (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##
 folderExists (folderPath$) – 1 if the folder exists and can be read, 0 otherwise
 folderNames$# (folderNameOrPattern$) – get the names (not the whole paths) of the subfolders in a folder or that match a pattern with an asterisk
 folderNames_caseInsensitive$# (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
 goto – place in a script to jump from
 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_caseInsensitive (string$, part$) – look up a substring, or 0 if not found
 index_caseInsensitive (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
 invSigmoid# (vector#) – inverse sigmoid of each element of vector#
 invSigmoid## (matrix##) – inverse sigmoid of each cell of matrix##
 invStudentQ (q, df) – inverse studentQ
 label – place in a script to jump to
 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##
 lowerCaseAppName$ ( ) – the name of the app in lower snake case, e.g. praat or praat_for_hospitals
 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
 minusObject (...) – shrink the selection of objects in the list
 mul## (a##, b##) – matrix multiplication
 ncol – the number of columns of an object
 nrow – the number of rows of an object
 number (a$) – interpret a string as a number
 number# (a$#) – interpret strings as numbers
 numberOfColumns (matrix##)
 numberOfRows (matrix##)
 nx – the number of cells horizontally (i.e. the number of columns) of an object
 ny – the number of cells vertically (i.e. the number of rows) of an object
 outer## (a#, b#) – outer product, i.e. resultij = aibj
 padLeft$ (string$, minimumNewWidth [, pad$]) – left padding
 padOrTruncateLeft$ (string$, newWidth [, pad$]) – left padding or truncation
 padOrTruncateRight$ (string$, newWidth [, pad$]) – right padding or truncation
 padRight$ (string$, minimumNewWidth [, pad$]) – right padding
 pauseScript (...) – show a message in a simple pause window
 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
 plusObject (...) – extend the selection of objects in the list
 procedure: procedureName, ... – start a procedure definition
 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 (mu, sigma) – normally distributed random deviate
 randomGauss# (n, mu, sigma) – n independent normally distributed random numbers
 randomGauss# (vector#, mu, sigma) – duplicate vector#, and replace all elements with independent normally distributed random numbers
 randomGauss## (nrow, ncol, mu, sigma) – nrow × ncol independent normally distributed random numbers
 randomGauss## (matrix##, mu, sigma) – 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
 randomInteger## (matrix##, min, max) – duplicate matrix##, and replace all cells with 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
 readFile# (filePath$) – read a vector from a text file
 readFile## (filePath$) – read a matrix from a text file
 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##
 removeObject (...) – remove objects from the list, by ID and/or name
 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 (strings$#, s$) – look up whether and where s$ last occurs in strings$#
 rindex_caseInsensitive (string$, part$) – look up a substring from the end, or 0 if not found
 rindex_caseInsensitive (strings$#, s$) – look up whether and where s$ last occurs in strings$#
 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##
 row – the row number (of the current cell) in a Formula command
 row$ [i] – the name of row i of an object
 row# (matrix##, rowNumber) - extract one row from a matrix
 rowSums# (matrix##)
 runScript (filePath$, ...) – run a script with the given arguments
 runSubprocess (executableFilePath$, ...) – run an external program with the given arguments
 runSubprocess$ (executableFilePath$, ...) – run an external program with the given arguments, and return its output
 runSystem (...) – run a system command line with the given arguments concatenated
 runSystem$ (...) – run a system command line with the given arguments concatenated, and return its output
 selected ( ) – the ID of the topmost selected object
 selected (i) – the ID of the ith selected object (as counted from the top, or from the bottom if negative)
 selected (type$) – the ID of the topmost selected object of type type$
 selected (type$, i) – the ID of the ith selected object of type type$ (as counted from the top, or from the bottom if negative)
 selected$ ( ) – the full name (type + given name) of the topmost selected object
 selected$ (i) – the full name (type + given name) of the ith selected object (as counted from the top, or from the bottom if negative)
 selected$ (type$) – the given name of the topmost selected object of type type$
 selected$ (type$, i) – the given name of the ith selected object of type type$ (as counted from the top, or from the bottom if negative)
 selected# ( ) – the IDs of all selected objects
 selected# (type$) – the IDs of all selected objects of type type$
 selected$# ( ) – the full names of all selected objects
 selected$# (type$) – the given names of all selected objects of type type$
 selectObject (...) – select object(s) in the list by ID and/or full name
 semitonesToHertz (x) – from logarithmic scale re 100 Hz to acoustic frequency
 sigmoid (x) – 1 / (1 + e-x)
 sigmoid# (vector#) – sigmoid of each element of vector#
 sigmoid## (matrix##) – sigmoid of each cell of matrix##
 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
 shuffle$# (stringVector$#) – randomize order
 sleep (duration) – pause script for duration seconds
 softmax# (vector#)
 softmaxPerRow## (matrix##)
 solve# (a##, y#) – find x for which A · x = y
 solve## (a##, y##) – find X for which A · X = Y
 solveNonnegative# (a##, y# [, x], maximumNumberOfIterations, tolerance, infoLevel)
 solveSparse# (a##, y# [, x], maximumNumberOfNonzeros, maximumNumberOfIterations, tolerance, infoLevel)
 solveWeaklyConstrained# (a##, y#, alpha, delta)
 sort# (vector#) – reshuffle in increasing order
 sort$# (stringVector$#) – reshuffle in Unicode-alphabetical order
 sort_numberAware$# (stringVector$#) – reshuffle in Unicode-alphabetical order, with special attention to numbers
 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$
 startsWith_caseInsensitive (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##) – flip matrix along its diagonal
 truncateLeft$ (string$, newMaximumWidth [, pad$]) – left truncation of string$
 truncateRight$ (string$, newMaximumWidth [, pad$]) – right truncation of string$
 tryToAppendFile (filePath$) – check whether a file can be appended to
 tryToWriteFile (filePath$) – check whether a file can be written (destructive!)
 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
 upperCaseAppName$ ( ) – the name of the app in upper camel case, e.g. Praat or PraatForHospitals
 variableExists (variableName$) – does the variable variableName$ exist?
 vertical$ (stringArray$#) – format a string array vertically
 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
 writeInfo (...) – write texts, numbers, vectors and so on, to a clear Info window
 writeInfoLine (...) – write texts, numbers, vectors and so on, followed by a newline, to a clear Info window
 x – the horizontal place (in world coordinates) of the current cell in a Formula command
 xmax – the top of the horizontal domain of an object
 xmin – the bottom of the horizontal domain of an object
 y – the vertical place (in world coordinates) of the current cell in a Formula command
 ymax – the top of the vertical domain of an object
 ymin – the bottom of the vertical domain of an object
 zero# (n) – vector with n elements that are all 0
 zero## (nrow, ncol) – matrix with nrow × ncol elements that are all 0

© Paul Boersma 2022-2024