Debian Codegraph @

fon/manual_functions.cpp

raw
1 /* manual_functions.cpp
2 *
3 * Copyright (C) 1992-2026 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "ManPagesM.h"
20
21 void manual_functions_init (ManPages me);
22 void manual_functions_init (ManPages me) {
23
24 MAN_PAGES_BEGIN R"~~~(
25 ################################################################################
26 "Functions"
27 © Paul Boersma 2022-2026
28
29 A growing list of functions that you can use in @formulas and @scripting...
30
31 , @`abs` (%`x`) – absolute value
32 , @`abs#` (%`vector#`) – absolute value of each element of %`vector#`
33 , @`abs##` (%`matrix##`) – absolute value of each cell of %`matrix##`
34 , @`appDay` ( ) – the month day at which the present version of Praat was built
35 , @`appendFile` (%`filePath$`, `...`) – write texts, numbers, vectors and so on
36 at the end of an existing file (create such a file if it does not exist yet)
37 , @`appendFileLine` (%`filePath$`, `...`) – write texts, numbers, vectors and so on,
38 followed by a newline, at the end of an existing file
39 (create such a file if it does not exist yet)
40 , @`appendInfo` (`...`) – write texts, numbers, vectors and so on,
41 to the Info window
42 , @`appendInfoLine` (`...`) – write texts, numbers, vectors and so on,
43 followed by a newline, to the Info window
44 , @`appMonth` ( ) – the month in which the present version of Praat was built (between 1 and 12)
45 , @`appMonth$` ( ) – the name of the month (in English) in which the present version of Praat was built
46 , @`appVersion` ( ) – the number of the present version of Praat
47 , @`appVersion$` ( ) – the present version of Praat, as text
48 , @`appYear` ( ) – the year in which the present version of Praat was built
49 , @`arccos` (%`x`) – inverse cosine
50 , @`arccos#` (%`vector#`) – inverse cosine of each element of %`vector#`
51 , @`arccos##` (%`matrix##`) – inverse cosine of each cell of %`matrix##`
52 , @`arccosh` (%`x`) – inverse hyperbolic cosine
53 , @`arccosh#` (%`vector#`) – inverse hyperbolic cosine of each element of %`vector#`
54 , @`arccosh##` (%`matrix##`) – inverse hyperbolic cosine of each cell of %`matrix##`
55 , @`arcsin` (%`x`) – inverse sine
56 , @`arcsin#` (%`vector#`) – inverse sine of each element of %`vector#`
57 , @`arcsin##` (%`matrix##`) – inverse sine of each cell of %`matrix##`
58 , @`arcsinh` (%`x`) – inverse hyperbolic sine
59 , @`arcsinh#` (%`vector#`) – inverse hyperbolic sine of each element of %`vector#`
60 , @`arcsinh##` (%`matrix##`) – inverse hyperbolic sine of each cell of %`matrix##`
61 , @`arctan` (%`x`) – inverse tangent
62 , @`arctan#` (%`vector#`) – inverse tangent of each element of %`vector#`
63 , @`arctan##` (%`matrix##`) – inverse tangent of each cell of %`matrix##`
64 , @`arctan2` (%`y`, %`x`) – argument angle
65 , @`arctanh` (%`x`) – inverse hyperbolic tangent
66 , @`arctanh#` (%`vector#`) – inverse hyperbolic tangent of each element of %`vector#`
67 , @`arctanh##` (%`matrix##`) – inverse hyperbolic tangent of each cell of %`matrix##`
68 , @`assert` %`condition` – condition checking
69 , @`asserterror` %`message$` – testing that a certain error occurs
70 , @`asynchronous` – let the script continue while the sound is playing or a subprocess is running
71 , @`backslashTrigraphsToUnicode$` (%`string$`) – convert e.g. \bsct to \ct
72 , @`barkToHertz` (%`x`) – from Bark-rate to acoustic frequency
73 , @`besselI` (%`n`, %`x`) – modified Bessel function of the first kind, %I__%n_
74 , @`besselK` (%`n`, %`x`) – modified Bessel function of the second kind, %K__%n_
75 , @`beta` (%`x`, %`y`) – \be function
76 , @`between_by#` (%`low`, %`high`, %`step`) – symmetrically dispersed numbers between %`low` and %`high`, in steps of %`step`
77 , @`between_count#` (%`low`, %`high`, %`n`) – %`n` symmetrically dispersed numbers between %`low` and %`high` (bin centres)
78 , @`binomialP` (%`p`, %`k`, %`n`) – probability of Bernoulli event occurring at most %`k` in %`n` times
79 , @`binomialQ` (%`p`, %`k`, %`n`) – probability of Bernoulli event occurring at least %`k` in %`n` times
80 , @`ceiling` (%x) – round up to integer
81 , @`ceiling#` (%`vector#`) – round up each element of %`vector#`
82 , @`ceiling##` (%`matrix##`) – round up each cell of %`matrix##`
83 , @`center` (%`v#`) – center (or centre) of gravity
84 , @`chiSquareP` (%`chiSquare`, %`df`) – area under the %\ci^2 curve up to %`chiSquare`
85 , @`chiSquareQ` (%`chiSquare`, %`df`) – area under the %\ci^2 curve after %`chiSquare`
86 , @`chooseFolder$` (%`title$`) – pops up a folder selection window
87 , @`chooseReadFile$` (%`title$`) – pops up a file selection window for opening (or appending to) an existing file
88 , @`chooseWriteFile$` (%`title$`, %`defaultFilename$`) – pops up a file selection window for saving to a new file
89 , @`clearinfo` – clear the Info window
90 , @`clock` ( ) – typically the number of seconds since system start-up
91 , @`col` – the columns number (of the current cell) in a Formula command
92 , @`col$` [%`i`] – the name of column %i of an object
93 , @`col#` (%`matrix##`, %`columnNumber`) - extract one column from a matrix
94 , @`columnSums#` (%`matrix##`)
95 , @`combine#` (...) - combine numbers, vectors and matrices into a new vector
96 , @`correlation` (%`u#`, %`v#`) – correlation (between \-m1 and +1) of two vectors
97 , @`cos` (%`x`) – cosine
98 , @`cos#` (%`vector#`) – cosine of each element of %`vector#`
99 , @`cos##` (%`matrix##`) – cosine of each cell of %`matrix##`
100 , @`cosh` (%x) – hyperbolic cosine
101 , @`cosh#` (%`vector#`) – hyperbolic cosine of each element of %`vector#`
102 , @`cosh##` (%`matrix##`) – hyperbolic cosine of each cell of %`matrix##`
103 , @`createFolder` (%`folderPath$`) – create a new folder, or do nothing if it already exists
104 , @`date$` ( ) – current local date and time in the form "Mon Nov 8 16:32:42 2021"
105 , @`date_iso$` ( ) – current local date and time in the form "2021-11-08T16:32:42+01:00"
106 , @`date#` ( ) – current local date and time in the form { 2021, 11, 8, 16, 32, 42 }
107 , @`date_utc$` ( ) – current standard date and time in the form "Mon Nov 8 15:32:42 2021"
108 , @`date_utc_iso$` ( ) – current standard date and time in the form "2021-11-08T15:32:42Z"
109 , @`date_utc#` ( ) – current standard date and time in the form { 2021, 11, 8, 15, 32, 42 }
110 , @`deleteFile` (%`filePath$`) – delete a file, or do nothing if it does not exist
111 , @`demo` – execute a graphics command in the Demo window (instead of in the Picture window)
112 , @`demoClicked` ( ) – determine whether the user clicked in the Demo window
113 , @`demoClickedIn` (%`xmin`, %`xmax`, %`ymmin`, %`ymax`) – determine whether the user clicked in a rectangular region in the Demo window
114 , @`demoCommandKeyPressed` ( ) – determine whether the user pressed the Command key when they typed into the Demo window
115 , @`demoInput` (%`characters$`) – determine whether the user typed (or clicked) the specified characters into the Demo window
116 , @`demoKey$` ( ) – determine the key that the user typed into the Demo window
117 , @`demoKeyPressed` ( ) – determine whether the user typed anything into the Demo window
118 , @`demoOptionKeyPressed` ( ) – determine whether the user pressed the Option key when they typed into the Demo window
119 , @`demoPeekInput` ( ) – see whether a user event (click or key press) is available in the Demo window
120 , @`demoShiftKeyPressed` ( ) – determine whether the user pressed the Shift key when they typed into the Demo window
121 , @`demoShow` ( ) – make all deferred drawing commands immediately visible
122 , @`demoWaitForInput` ( ) – wait for a user event (click or key press) in the Demo window
123 , @`demoWindowTitle` (%`newTitle$`) – change the title of the Demo window
124 , @`demoX` ( ) – the horizontal position of a mouse click in the Demo window
125 , @`demoY` ( ) – the vertical position of a mouse click in the Demo window
126 , @`differenceLimensToPhon` (%`x`) – from jnd-scale to perceptual loudness
127 , @`dx` – the horizontal distance between cells (i.e. the distance between columns) of an object
128 , @`dy` – the vertical distance between cells (i.e. the distance between rows) of an object
129 , @`editor` (%`editor($)`) – enter the environment of an editor (by number or by name)
130 , @`empty$#` (%`numberOfStrings`) – create an array of empty strings
131 , @`endeditor` – leave the environment of an editor
132 , @`endproc` – end a procedure definition
133 , @`endsWith` (%`string$`, %`part$`) – determine whether %`string$` ends in %`part$`
134 , @`endsWith_caseInsensitive` (%`string$`, %`part$`) – determine whether %`string$` ends in %`part$`
135 , @`environment$` (%`string$`) – look up a system environment string
136 , @`erb` (%`f`) – equivalent rectangular bandwidth for frequency %`f`
137 , @`erbToHertz` (%`x`) – from ERB-rate to acoustic frequency
138 , @`erf` (%`x`) – error function, the integral of the Gaussian
139 , @`erfc` (%`x`) – complement of the error function, i.e. 1 − erf (%`x`);
140 this is a separate function because erf (%`x`) can be close to 1
141 , @`exitScript` (`...`) – show a message that tells the user why the script will be interrupted
142 , @`exp` (%`x`) – exponentiation, i.e. %e^%`x`
143 , @`exp#` (%`vector#`) – exponentiate each element of %`vector#`
144 , @`exp##` (%`matrix##`) – exponentiate each cell of %`matrix##`
145 , @`extractLine$` (%`string$`, %`part$`) – everything that comes after the first occurrence of %`part$` in %`string$`
146 , @`extractNumber` (%`string$`, %`part$`) – the first number after the first occurrence of %`part$% in %`string$`
147 , @`extractWord$` (%`string$`, %`part$`) – the first “word” after the first occurrence of %`part$% in %`string$`
148 , @`fileNames$#` (%`folderNameOrPattern$`) – get the names (not the whole paths) of the files in a folder
149 or that match a pattern with an asterisk
150 , @`fileNames_caseInsensitive$#` (%`folderNameOrPattern$`) – get the names (not the whole paths) of the files in a folder
151 or that match a pattern with an asterisk
152 , @`fileReadable` (%`filePath$`) – 1 if the file exists and can be read, 0 otherwise
153 , @`fisherP` (%`f`, %`df1`, %`df2`) – area under the Fisher %F curve up to %`f`
154 , @`fisherQ` (%`f`, %`df1`, %`df2`) – area under the Fisher %F curve after %`f`
155 , @`fixed$` (%`number`, %`precision`) – format a number as a string, with %`precision` digits after the decimal point
156 , @`fixed$` (%`vector#`, %`precision`) – format a vector as a string, with all elements expressed in %`precision` digits after the decimal point
157 , @`fixed$` (%`matrix##`, %`precision`) – format a matrix as a string, with all cells expressed in %`precision` digits after the decimal point
158 , @`floor` (%`x`) – round down to integer
159 , @`floor#` (%`vector#`) – round down each element of %`vector#`
160 , @`floor##` (%`matrix##`) – round down each cell of %`matrix##`
161 , @`folderExists` (%`folderPath$`) – 1 if the folder exists and can be read, 0 otherwise
162 , @`folderNames$#` (%`folderNameOrPattern$`) – get the names (not the whole paths) of the subfolders in a folder
163 or that match a pattern with an asterisk
164 , @`folderNames_caseInsensitive$#` (%`folderNameOrPattern$`) – get the names (not the whole paths) of the subfolders in a folder
165 or that match a pattern with an asterisk
166 , @`from_to#` (%`m`, %`n`) – the integers from %`m` through %`n`
167 , @`from_to_by#` (%`m`, %`n`, %`step`) – numbers from %`m` through %`n`, in steps of %`step`
168 , @`from_to_count#` (%`start`, %`end`, %`n`) – %`n` numbers from %`start` through %`end`
169 , @`gaussP` (%`z`) – area under the normal curve up to %`z`
170 , @`gaussQ` (%`z`) – area under the normal curve after %`z`
171 , @`goto` – place in a script to jump from
172 , @`hertzToBark` (%`x`) – from acoustic frequency to Bark-rate
173 , @`hertzToErb` (%`x`) – from acoustic frequency to ERB-rate
174 , @`hertzToMel` (%`x`) – from acoustic frequency to mel
175 , @`hertzToSemitones` (%`x`) – from acoustic frequency to logarithmic scale %re 100 Hz
176 , @`imax` (%`x`, `...`) – location of the maximum
177 , @`imin` (%`x`, `...`) – location of the minimum
178 , @`index` (%`string$`, %`part$`) – look up a substring, or 0 if not found
179 , @`index` (%`strings$#`, %`s$`) – look up whether and where %`s$` first occurs in %`strings$`
180 , @`index_caseInsensitive` (%`string$`, %`part$`) – look up a substring, or 0 if not found
181 , @`index_caseInsensitive` (%`strings$#`, %`s$`) – look up whether and where %`s$` first occurs in %`strings$`
182 , @`index_regex` (%`string$`, %`regex$`) – determine whether and where %`string$` first matches %`regex$`
183 , @`inner` (%`a#`, %`b#`) – inner product
184 , @`invBinomialP` (%`P`, %`k`, %`n`) – inverse of `binomialP`
185 , @`invBinomialQ` (%`Q`, %`k`, %`n`) – inverse of `binomialQ`
186 , @`invChiSquareQ` (%`q`, %`df`) – inverse of `chiSquareQ`
187 , @`invFisherQ` (%`q`, %`df1`, %`df2`) – inverse of `fisherQ`
188 , @`invGaussQ` (%`z`) – inverse of `gaussQ`
189 , @`invSigmoid` (%`x`) – inverse `sigmoid`
190 , @`invSigmoid#` (%`vector#`) – inverse sigmoid of each element of %`vector#`
191 , @`invSigmoid##` (%`matrix##`) – inverse sigmoid of each cell of %`matrix##`
192 , @`invStudentQ` (%`q`, %`df`) – inverse studentQ
193 , @`label` – place in a script to jump to
194 , @`left$` (%`string$`, %`n`) – the %n first characters in %`string$`
195 , @`length` (%`string$`) – number of Unicode characters in %`string$`
196 , @`ln` (%`x`) – natural logarithm, base %e
197 , @`ln#` (%`vector#`) – natural logarithm of each element of %`vector#`
198 , @`ln##` (%`matrix##`) – natural logarithm of each cell of %`matrix##`
199 , @`lnGamma` (%`x`) – logarithm of the \Ga function
200 , @`log2` (%`x`) – logarithm, base 2
201 , @`log2#` (%`vector#`) – base-2 logarithm of each element of %`vector#`
202 , @`log2##` (%`matrix##`) – base-2 logarithm of each cell of %`matrix##`
203 , @`log10` (%x) – logarithm, base 10
204 , @`log10#` (%`vector#`) – base-10 logarithm of each element of %`vector#`
205 , @`log10##` (%`matrix##`) – base-10 logarithm of each cell of %`matrix##`
206 , @`lowerCase$` (%`string$`) – turns all capitals into lower case
207 , @`lowerCaseAppName$` ( ) – the name of the app in lower snake case, e.g. `praat` or `praat_for_hospitals`
208 , @`max` (%`x`, `...`) – maximum
209 , @`mean` (%`v#`) – average of the elements of a vector
210 , @`melToHertz` (%`x`) – from mel to acoustic frequency
211 , @`mid$` (%`string$`, %`from`, %`n`) – the %`n` characters in %`string$` starting at position %`from`
212 , @`min` (%`x`, `...`) – minimum
213 , @`minusObject` (`...`) – shrink the selection of objects in the list
214 , @`moveAndOrRenameFile` (%`fromFilePath$`, %`toFilePath$`) – move and/or rename a file (note: supply two paths)
215 , @`mul##` (%`a##`, %`b##`) – matrix multiplication
216 , @`ncol` – the number of columns of an object
217 , @`nrow` – the number of rows of an object
218 , @`number` (%`a$`) – interpret a string as a number
219 , @`number#` (%`a$#`) – interpret strings as numbers
220 , @`numberOfColumns` (%`matrix##`)
221 , @`numberOfRows` (%`matrix##`)
222 , @`nx` – the number of cells horizontally (i.e. the number of columns) of an object
223 , @`ny` – the number of cells vertically (i.e. the number of rows) of an object
224 , @`outer##` (%`a#`, %`b#`) – outer product, i.e. %%result__ij_% = %%a__i_%%%b__j_%
225 , @`padLeft$` (%`string$`, %`minimumNewWidth` [, %`pad$`]) – left padding
226 , @`padOrTruncateLeft$` (%`string$`, %`newWidth` [, %`pad$`]) – left padding or truncation
227 , @`padOrTruncateRight$` (%`string$`, %`newWidth` [, %`pad$`]) – right padding or truncation
228 , @`padRight$` (%`string$`, %`minimumNewWidth` [, %`pad$`]) – right padding
229 , @`pauseScript` (`...`) – show a message in a simple @@pause window@
230 , @`percent$` (%`number`, %`precision`) – format a number as a string,
231 with a trailing percent sign and %`precision` digits after the decimal point
232 , @`phonToDifferenceLimens` (%`x`) – from perceptual loudness to jnd-scale
233 , @`plusObject` (`...`) – extend the selection of objects in the list
234 , @`procedure`: %`procedureName`, `...` – start a procedure definition
235 , @`randomBernoulli` (%`p`) – Bernoulli-distributed random deviate (0 or 1)
236 , @`randomBernoulli#` (%`n`, %`p`) – %`n` independent Bernoulli-distributed zeroes and ones
237 , @`randomGamma` (%`shape`, %`rate`) – gamma-distributed random deviate
238 , @`randomGamma#` (%`n`, %`shape`, %`rate`) – %n independent gamma-distributed random numbers
239 , @`randomGamma#` (%`vector#`, %`shape`, %`rate`) – duplicate %`vector#`,
240 and replace all elements with independent gamma-distributed random numbers
241 , @`randomGamma##` (%`nrow`, %`ncol`, %`shape`, %`rate`) – %nrow \xx %ncol independent gamma-distributed random numbers
242 , @`randomGamma##` (%`matrix##`, %`shape`, %`rate`) – duplicate %`matrix##`,
243 and replace all cells with independent gamma-distributed random numbers
244 , @`randomGauss` (%`mu`, %`sigma`) – normally distributed random deviate
245 , @`randomGauss#` (%`n`, %`mu`, %`sigma`) – %n independent normally distributed random numbers
246 , @`randomGauss#` (%`vector#`, %`mu`, %`sigma`) – duplicate %`vector#`,
247 and replace all elements with independent normally distributed random numbers
248 , @`randomGauss##` (%`nrow`, %`ncol`, %`mu`, %`sigma`) – %`nrow` \xx %`ncol` independent normally distributed random numbers
249 , @`randomGauss##` (%`matrix##`, %`mu`, %`sigma`) – duplicate %`matrix##`,
250 and replace all cells with independent normally distributed random numbers
251 , @`randomImax` (%`vector#`) – sample from an array of relative probabilities
252 , @`randomInteger` (%`min`, %`max`) – uniformly distributed integer random deviate
253 , @`randomInteger#` (%`n`, %`min`, %`max`) – %`n` independent uniformly distributed random integers
254 , @`randomInteger#` (%`vector#`, %`min`, %`max`) – duplicate %`vector#`,
255 and replace all elements with independent uniformly distributed random integers
256 , @`randomInteger##` (%`nrow`, %`ncol`, %`min`, %`max`) – %`nrow` \xx %`ncol` independent uniformly distributed random integers
257 , @`randomInteger##` (%`matrix##`, %`min`, %`max`) – duplicate %`matrix##`,
258 and replace all cells with independent uniformly distributed random integers
259 , @`randomPoisson` (%`mean`) – Poisson-distributed random deviate
260 , @`randomPoisson#` (%`n`, %`mean`) – %`n` independent Poisson-distributed random numbers
261 , @`randomPoisson#` (%`vector#`, %`mean`) – duplicate %`vector#`,
262 and replace all elements with independent Poisson-distributed random numbers
263 , @`randomPoisson##` (%nrow, %ncol, %`mean`) – %`nrow` \xx %`ncol` independent Poisson-distributed random numbers
264 , @`randomPoisson##` (%`matrix##`, %`mean`) – duplicate %`matrix##`,
265 and replace all cells with independent Poisson-distributed random numbers
266 , @`randomUniform` (%`min`, %`max`) – uniformly distributed random deviate
267 , @`randomUniform#` (%`n`, %`min`, %`max`) – %n independent uniformly distributed random numbers
268 , @`randomUniform#` (%`vector#`, %min, %max) – duplicate %`vector#`,
269 and replace all elements with independent uniformly distributed random numbers
270 , @`randomUniform##` (%`nrow`, %`ncol`, %`min`, %`max`) – %`nrow` \xx %`ncol` independent uniformly distributed random numbers
271 , @`randomUniform##` (%`matrix##`, %`min`, %`max`) – duplicate %`matrix##`,
272 and replace all cells with independent uniformly distributed random numbers
273 , @`random_initializeSafelyAndUnpredictably` ( ) – undoes the effects of the following function
274 , @`random_initializeWithSeedUnsafelyButPredictably` (%`seed`) – reproducible sequence of random numbers
275 , @`readFile` (%`filePath$`) – read a number from a text file
276 , @`readFile$` (%`filePath$`) – read a whole text file into a string
277 , @`readFile#` (%`filePath$`) – read a vector from a text file
278 , @`readFile##` (%`filePath$`) – read a matrix from a text file
279 , @`readLinesFromFile$#` (%`filePath$`) – read all lines from a text file
280 , @`rectify` (%`x`) – set to zero if negative (no change if positive)
281 , @`rectify#` (%`vector#`) – rectify each element of %`vector#`
282 , @`rectify##` (%`matrix##`) – rectify each cell of %`matrix##`
283 , @`removeObject` (`...`) – remove objects from the list, by ID and/or name
284 , @`repeat#` (%`v#`, %`n`) – repeat the whole sequence of elements of %`v#` %`n` times
285 , @`replace$` (%`a$`, %`b$`, %`c$`, %`n`) – within %`a$`, replace the first %`n` occurrences of %`b$` with %`c$`, or all if %`n` = 0
286 , @`replace_regex$` (%`a$`, %`b$`, %`c$`, %`n`) – within %`a$`,
287 replace the first %`n` matches of regular expression %`b$` with the regular expression %`c$`, or all if %`n` = 0
288 , @`right$` (%`string$`, %`n`) – the %n last characters in %`string$`
289 , @`rindex` (%`string$`, %`part$`) – look up a substring from the end, or 0 if not found
290 , @`rindex` (%`strings$#`, %`s$`) – look up whether and where %`s$` last occurs in %`strings$#`
291 , @`rindex_caseInsensitive` (%`string$`, %`part$`) – look up a substring from the end, or 0 if not found
292 , @`rindex_caseInsensitive` (%`strings$#`, %`s$`) – look up whether and where %`s$` last occurs in %`strings$#`
293 , @`rindex_regex` (%`string$`, %`regex$`) – determine whether and where %`string$` last matches %`regex$`
294 , @`round` (%`x`) – nearest integer
295 , @`round#` (%`vector#`) – nearest integer of each element of %`vector#`
296 , @`round##` (%`matrix##`) – nearest integer of each cell of %`matrix##`
297 , @`row` – the row number (of the current cell) in a Formula command
298 , @`row$` [%`i`] – the name of row %i of an object
299 , @`row#` (%`matrix##`, %`rowNumber`) - extract one row from a matrix
300 , @`rowSums#` (%`matrix##`)
301 , @`runScript` (%`filePath$`, `...`) – run a script with the given arguments
302 , @`runSubprocess` (%`executableFilePath$`, `...`) – run an external program with the given arguments
303 , @`runSubprocess$` (%`executableFilePath$`, `...`) – run an external program with the given arguments, and return its output
304 , @`runSystem` (`...`) – run a system command line with the given arguments concatenated
305 , @`runSystem$` (`...`) – run a system command line with the given arguments concatenated, and return its output
306 , @`selected` ( ) – the ID of the topmost selected object
307 , @`selected` (%`i`) – the ID of the %%i%th selected object (as counted from the top, or from the bottom if negative)
308 , @`selected` (%`type$`) – the ID of the topmost selected object of type %`type$`
309 , @`selected` (%`type$`, %`i`) – the ID of the %%i%th selected object of type %`type$` (as counted from the top,
310 or from the bottom if negative)
311 , @`selected$` ( ) – the full name (type + given name) of the topmost selected object
312 , @`selected$` (%`i`) – the full name (type + given name) of the %%i%th selected object (as counted from the top,
313 or from the bottom if negative)
314 , @`selected$` (%`type$`) – the given name of the topmost selected object of type %`type$`
315 , @`selected$` (%`type$`, %`i`) – the given name of the %%i%th selected object of type %`type$` (as counted from the top,
316 or from the bottom if negative)
317 , @`selected#` ( ) – the IDs of all selected objects
318 , @`selected#` (%`type$`) – the IDs of all selected objects of type %`type$`
319 , @`selected$#` ( ) – the full names of all selected objects
320 , @`selected$#` (%`type$`) – the given names of all selected objects of type %`type$`
321 , @`selectObject` (`...`) – select object(s) in the list by ID and/or full name
322 , @`semitonesToHertz` (%`x`) – from logarithmic scale %re 100 Hz to acoustic frequency
323 , @`sigmoid` (%`x`) – 1 / (1 + %e^^-%`x`^)
324 , @`sigmoid#` (%`vector#`) – sigmoid of each element of %`vector#`
325 , @`sigmoid##` (%`matrix##`) – sigmoid of each cell of %`matrix##`
326 , @`sin` (%`x`) – sine
327 , @`sin#` (%`vector#`) – sine of each element of %`vector#`
328 , @`sin##` (%`matrix##`) – sine of each cell of %`matrix##`
329 , @`sinc` (%`x`) – sinus cardinalis: sin (%`x`) / %`x`
330 , @`sincpi` (%`x`) – sin (%\pi%x) / (%\pi%x)
331 , @`sinh` (%`x`) – hyperbolic sine
332 , @`sinh#` (%`vector#`) – hyperbolic sine of each element of %`vector#`
333 , @`sinh##` (%`matrix##`) – hyperbolic sine of each cell of %`matrix##`
334 , @`size` (%`v#`) – number of elements
335 , @`shuffle#` (%`vector#`) – randomize order
336 , @`shuffle$#` (%`stringVector$#`) – randomize order
337 , @`sleep` (%`duration`) – pause script for %`duration` seconds
338 , @`softmax#` (%`vector#`)
339 , @`softmaxPerRow##` (%`matrix##`)
340 , @`solve#` (%`a##`, %`y#`) – find #x for which #A · #x = #y
341 , @`solve##` (%`a##`, %`y##`) – find #X for which #A · #X = #Y
342 , @`solveNonnegative#` (%`a##`, %`y#` [, %`x`], %`maximumNumberOfIterations`, %`tolerance`, %`infoLevel`)
343 , @`solveSparse#` (%`a##`, %`y#` [, %`x`], %`maximumNumberOfNonzeros`, %`maximumNumberOfIterations`, %`tolerance`, %`infoLevel`)
344 , @`solveWeaklyConstrained#` (%`a##`, %`y#`, %`alpha`, %`delta`)
345 , @`sort#` (%`vector#`) – reshuffle in increasing order
346 , @`sort$#` (%`stringVector$#`) – reshuffle in Unicode-alphabetical order
347 , @`sort_numberAware$#` (%`stringVector$#`) – reshuffle in Unicode-alphabetical order, with special attention to numbers
348 , @`splitByWhitespace$#` (%`string$`) – split a string into inks
349 , @`sqrt` (%`x`) – square root
350 , @`sqrt#` (%`vector#`) – square root of each element of %`vector#`
351 , @`sqrt##` (%`matrix##`) – square root of each cell of %`matrix##`
352 , @`startsWith` (%`string$`, %`part$`) – determine whether %`string$` starts with %`part$`
353 , @`startsWith_caseInsensitive` (%`string$`, %`part$`) – determine whether %`string$` starts with %`part$`
354 , @`stdev` (%`v#`) – standard deviation of the elements of a vector
355 , @`stopwatch` – give the current value of the timer, which is then immediately reset to zero (note: no parentheses)
356 , @`string$` (%`number`) – format a number as a string
357 , @`studentP` (%`t`, %`df`) – area under the Student %T curve up to %`t`
358 , @`studentQ` (%`t`, %`df`) – area under the Student %T curve after %`t`
359 , @`sum` (%`v#`) – sum the elements
360 , @`sumOver` (%`loopVariable` `to` %`n`, %`numericExpressionOptionallyUsingLoopVariable`) – \Si
361 , @`tan` (%`x`) – tangent
362 , @`tan#` (%`vector#`) – tangent of each element of %`vector#`
363 , @`tan##` (%`matrix##`) – tangent of each cell of %`matrix##`
364 , @`tanh` (%`x`) – hyperbolic tangent
365 , @`tanh#` (%`vector#`) – hyperbolic tangent of each element of %`vector#`
366 , @`tanh##` (%`matrix##`) – hyperbolic tangent of each cell of %`matrix##`
367 , @`to#` (%`n`) – the integers 1 through %`n`
368 , @`transpose##` (%`matrix##`) – flip matrix along its diagonal
369 , @`truncateLeft$` (%`string$`, %`newMaximumWidth` [, %`pad$`]) – left truncation of %`string$`
370 , @`truncateRight$` (%`string$`, %`newMaximumWidth` [, %`pad$`]) – right truncation of %`string$`
371 , @`tryToAppendFile` (%`filePath$`) – check whether a file can be appended to
372 , @`tryToWriteFile` (%`filePath$`) – check whether a file can be written (destructive!)
373 , @`unicode` (%`c$`) – the Unicode codepoint number that corresponds to character %`c$`
374 , @`unicode$` (%`n`) – the character that corresponds to Unicode codepoint %`n`
375 , @`unicodeToBackslashTrigraphs$` (%`string$`) – convert e.g. \ct to \bsct
376 , @`upperCase$` (%`string$`) – turns all lower-case characters into capitals
377 , @`upperCaseAppName$` ( ) – the name of the app in upper camel case, e.g. `Praat` or `PraatForHospitals`
378 , @`variableExists` (%`variableName$`) – does the variable %`variableName$` exist?
379 , @`vertical$` (%`stringArray$#`) – format a string array vertically
380 , @`writeFile` (%`filePath$`, `...`) – create a new text file, and write texts, numbers, vectors and so on into it
381 , @`writeFileLine` (%`filePath$`, `...`) – create a new text file, write texts, numbers, vectors and so on into it, followed by a newline
382 , @`writeInfo` (`...`) – write texts, numbers, vectors and so on, to a clear Info window
383 , @`writeInfoLine` (`...`) – write texts, numbers, vectors and so on, followed by a newline, to a clear Info window
384 , @`x` – the horizontal place (in world coordinates) of the current cell in a Formula command
385 , @`xmax` – the top of the horizontal domain of an object
386 , @`xmin` – the bottom of the horizontal domain of an object
387 , @`y` – the vertical place (in world coordinates) of the current cell in a Formula command
388 , @`ymax` – the top of the vertical domain of an object
389 , @`ymin` – the bottom of the vertical domain of an object
390 , @`zero#` (%`n`) – vector with %`n` elements that are all 0
391 , @`zero##` (%`nrow`, %`ncol`) – matrix with %`nrow` \xx %`ncol` elements that are all 0
392
393 ################################################################################
394 "`abs`"
395 © Paul Boersma 2023
396
397 A function that can be used in @@Formulas@. The absolute value.
398
399 Syntax and semantics
400 ====================
401 #`abs` (%`x`)
402 : compute the absolute value of %`x`.
403
404 Examples
405 ========
406 {
407 writeInfoLine: \#{abs} (3.14), " ", \#{abs} (0), " ", \#{abs} (-789e-300)
408 }
409
410 ################################################################################
411 "`abs#`"
412 © Paul Boersma 2023
413
414 A function that can be used in @@Formulas@.
415
416 Syntax and semantics
417 ====================
418 #`abs#` (%`v#`)
419 : compute the absolute value (@`abs`) of each element of the vector %`v#`.
420
421 Examples
422 ========
423 {
424 a# = \#{abs#} ({ -1, 5.5, 0, -456.789 })
425 writeInfoLine: a#
426 }
427
428 ################################################################################
429 "`abs##`"
430 © Paul Boersma 2023
431
432 A function that can be used in @@Formulas@.
433
434 Syntax and semantics
435 ====================
436 #`abs##` (%`m##`)
437 : compute the absolute value (@`abs`) of each cell of the matrix %`m##`.
438
439 Examples
440 ========
441 {
442 a## = \#{abs##} ({{ -1, 5.5, 0, -456.789 }, { 34, -45, 18.0, 0 },
443 ... { 1e-89, -3.2e-307, 6e200, -2345e-2 }})
444 writeInfoLine: a##
445 }
446
447 ################################################################################
448 "`appDay`"
449 © Paul Boersma 2024
450
451 A function that can be used in @@Formulas@. The month day on which the present version of Praat was built
452 (a number between 1 and 31).
453
454 Syntax and semantics
455 ====================
456 #`appDay` ( )
457 : give the month day of the creation of the present version of Praat.
458
459 Examples
460 ========
461 {
462 writeInfoLine: \#{appDay} ( )
463 }
464
465 ################################################################################
466 "`appendFile`"
467 © Paul Boersma 2023
468
469 A function that can be used in @Scripting.
470
471 Syntax and semantics
472 ====================
473 #`appendFile` (%`filePath$`, `...`)
474 : write texts, numbers, vectors and so on
475 at the end of an existing file (create such a file if it does not exist yet)
476
477 ################################################################################
478 "`appendFileLine`"
479 © Paul Boersma 2023
480
481 A function that can be used in @Scripting.
482
483 Syntax and semantics
484 ====================
485 #`appendFileLine` (%`filePath$`, `...`)
486 : write texts, numbers, vectors and so on, followed by a newline,
487 at the end of an existing file (create such a file if it does not exist yet)
488
489 ################################################################################
490 "`appendInfo`"
491 © Paul Boersma 2023
492
493 A function that can be used in @Scripting.
494
495 Syntax and semantics
496 ====================
497 #`appendInfo` (%`filePath$`, `...`)
498 : write texts, numbers, vectors and so on
499 to the end of the Info window
500
501 ################################################################################
502 "`appendInfoLine`"
503 © Paul Boersma 2023
504
505 A function that can be used in @Scripting.
506
507 Syntax and semantics
508 ====================
509 #`appendInfoLine` (%`filePath$`, `...`)
510 : write texts, numbers, vectors and so on, followed by a newline,
511 to the end of the Info window
512
513 ################################################################################
514 "`appMonth`"
515 © Paul Boersma 2024
516
517 A function that can be used in @@Formulas@. The number of the month in which the present version of Praat was built
518 (a number between 1 and 12).
519
520 Syntax and semantics
521 ====================
522 #`appMonth` ( )
523 : give the month of the creation of the present version of Praat, as a number.
524
525 Examples
526 ========
527 {
528 writeInfoLine: \#{appMonth} ( )
529 }
530
531 ################################################################################
532 "`appMonth$`"
533 © Paul Boersma 2024
534
535 A function that can be used in @@Formulas@. The name of the month in which the present version of Praat was built.
536
537 Syntax and semantics
538 ====================
539 #`appMonth$` ( )
540 : give the month of the creation of the present version of Praat, as text.
541
542 Examples
543 ========
544 {
545 writeInfoLine: \#{appMonth$} ( )
546 }
547
548 ################################################################################
549 "`appVersion`"
550 © Paul Boersma 2024
551
552 A function that can be used in @@Formulas@. The present version of Praat, as a number.
553
554 Syntax and semantics
555 ====================
556 #`appVersion` ( )
557 : give the present version of Praat, as a number.
558
559 Examples
560 ========
561 {
562 writeInfoLine: \#{appVersion} ( )
563 }
564
565 ################################################################################
566 "`appVersion$`"
567 © Paul Boersma 2024
568
569 A function that can be used in @@Formulas@. The present version of Praat, as text.
570
571 Syntax and semantics
572 ====================
573 #`appVersion$` ( )
574 : give the present version of Praat, as text.
575
576 Examples
577 ========
578 {
579 writeInfoLine: \#{appVersion$} ( )
580 }
581
582 ################################################################################
583 "`appYear`"
584 © Paul Boersma 2024
585
586 A function that can be used in @@Formulas@. The year in which the present version of Praat was built.
587
588 Syntax and semantics
589 ====================
590 #`appYear` ( )
591 : give the year of the creation of the present version of Praat.
592
593 Examples
594 ========
595 {
596 writeInfoLine: \#{appYear} ( )
597 }
598
599 ################################################################################
600 "`arccos`"
601 © Paul Boersma 2023
602
603 A function that can be used in @@Formulas@.
604
605 Syntax and semantics
606 ====================
607 #`arccos` (%`x`)
608 : compute the inverse cosine of %`x`.
609
610 Domain
611 ======
612 #`arccos` (%x) is defined for -1 \<_ %x \<_ 1.
613
614 Tests
615 =====
616 {
617 \`{assert} \#{arccos} (-1.1) = undefined
618 \`{assert} \`{abs} (\#{arccos} (-1.0) - pi) < 1e-17
619 \`{assert} \`{abs} (\#{arccos} (0.0) - pi/2) < 1e-17
620 \`{assert} \#{arccos} (1.0) = 0
621 \`{assert} \#{arccos} (1.1) = undefined
622 \`{assert} \#{arccos} (undefined) = undefined
623 }
624
625 ################################################################################
626 "`arccos#`"
627 © Paul Boersma 2023
628
629 A function that can be used in @@Formulas@.
630
631 Syntax and semantics
632 ====================
633 #`arccos#` (%`v#`)
634 : compute the inverse cosine (@`arccos`) of each element of the vector %`v#`.
635
636 Examples
637 ========
638 {
639 writeInfoLine: \#{arccos#} ({ -1.1, -1.0, 0.0, 1.0, 1.1, undefined })
640 }
641
642 ################################################################################
643 "`arccos##`"
644 © Paul Boersma 2023
645
646 A function that can be used in @@Formulas@.
647
648 Syntax and semantics
649 ====================
650 #`arccos##` (%`m##`)
651 : compute the inverse cosine (@`arccos`) of each cell of the matrix %`m##`.
652
653 ################################################################################
654 "`arccosh`"
655 © Paul Boersma 2023
656
657 A function that can be used in @@Formulas@.
658
659 Syntax and semantics
660 ====================
661 #`arccosh` (%`x`)
662 : compute the inverse hyperbolic cosine of %`x`.
663
664 Definition
665 ==========
666 ~ #`arccosh` (%x) = ln (%x + \Vr(%x^2−1))
667
668 Tests
669 =====
670 {
671 \`{assert} \#{arccosh} (1.0) = 0
672 \`{assert} \#{arccosh} (0.9) = undefined
673 \`{assert} \#{arccosh} (0.0) = undefined
674 \`{assert} \#{arccosh} (-10.0) = undefined
675 \`{assert} \#{arccosh} (undefined) = undefined
676 }
677
678 ################################################################################
679 "`arccosh#`"
680 © Paul Boersma 2023
681
682 A function that can be used in @@Formulas@.
683
684 Syntax and semantics
685 ====================
686 #`arccosh#` (%`v#`)
687 : compute the inverse hyperbolic cosine (@`arccosh`) of each element of the vector %`v#`.
688
689 ################################################################################
690 "`arccosh##`"
691 © Paul Boersma 2023
692
693 A function that can be used in @@Formulas@.
694
695 Syntax and semantics
696 ====================
697 #`arccosh##` (%`m##`)
698 : compute the inverse hyperbolic cosine (@`arccosh`) of each cell of the matrix %`m##`.
699
700 ################################################################################
701 "`arcsin`"
702 © Paul Boersma 2023
703
704 A function that can be used in @@Formulas@.
705
706 Syntax and semantics
707 ====================
708 #`arcsin` (%`x`)
709 : compute the inverse sine of %`x`.
710
711 Domain
712 ======
713 #`arcsin` (%x) is defined for -1 \<_ %x \<_ 1.
714
715 Tests
716 =====
717 {
718 \`{assert} \#{arcsin} (-1.1) = undefined
719 \`{assert} \`{abs} (\#{arcsin} (-1.0) - -pi/2) < 1e-17
720 \`{assert} \#{arcsin} (0.0) = 0
721 \`{assert} \`{abs} (\#{arcsin} (1.0) - pi/2) < 1e-17
722 \`{assert} \#{arcsin} (1.1) = undefined
723 \`{assert} \#{arcsin} (undefined) = undefined
724 }
725
726 ################################################################################
727 "`arcsin#`"
728 © Paul Boersma 2023
729
730 A function that can be used in @@Formulas@.
731
732 Syntax and semantics
733 ====================
734 #`arcsin#` (%`v#`)
735 : compute the inverse sine (@`arcsin`) of each element of the vector %`v#`.
736
737 ################################################################################
738 "`arcsin##`"
739 © Paul Boersma 2023
740
741 A function that can be used in @@Formulas@.
742
743 Syntax and semantics
744 ====================
745 #`arcsin##` (%`m##`)
746 : compute the inverse sine (@`arcsin`) of each cell of the matrix %`m##`.
747
748 ################################################################################
749 "`arcsinh`"
750 © Paul Boersma 2023
751
752 A function that can be used in @@Formulas@.
753
754 Syntax and semantics
755 ====================
756 #`arcsinh` (%`x`)
757 : compute the inverse hyperbolic sine of %`x`.
758
759 Definition
760 ==========
761 ~ #`arcsinh` (%x) = ln (%x + \Vr(1+%x^2))
762
763 Tests
764 =====
765 {
766 \`{assert} \#{arcsinh} (-1.0) < 0
767 \`{assert} \#{arcsinh} (0.0) = 0
768 \`{assert} \#{arcsinh} (1.0) > 0
769 \`{assert} \#{arcsinh} (undefined) = undefined
770 }
771
772 ################################################################################
773 "`arcsinh#`"
774 © Paul Boersma 2023
775
776 A function that can be used in @@Formulas@.
777
778 Syntax and semantics
779 ====================
780 #`arcsinh#` (%`v#`)
781 : compute the inverse hyperbolic sine (@`arcsinh`) of each element of the vector %`v#`.
782
783 ################################################################################
784 "`arcsinh##`"
785 © Paul Boersma 2023
786
787 A function that can be used in @@Formulas@.
788
789 Syntax and semantics
790 ====================
791 #`arcsin##` (%`m##`)
792 : compute the inverse hyperbolic sine (@`arcsinh`) of each cell of the matrix %`m##`.
793
794 ################################################################################
795 "`arctan`"
796 © Paul Boersma 2023
797
798 A function that can be used in @@Formulas@.
799
800 Syntax and semantics
801 ====================
802 #`arctan` (%`x`)
803 : compute the inverse tangent of (%`x`).
804
805 Tests
806 =====
807 {
808 \`{assert} \#{arctan} (0.0) = 0
809 }
810
811 ################################################################################
812 "`arctan#`"
813 © Paul Boersma 2023
814
815 A function that can be used in @@Formulas@.
816
817 Syntax and semantics
818 ====================
819 #`arctan#` (%`v#`)
820 : compute the inverse tangent (@`arctan`) of each element of the vector %`v#`.
821
822 ################################################################################
823 "`arctan##`"
824 © Paul Boersma 2023
825
826 A function that can be used in @@Formulas@.
827
828 Syntax and semantics
829 ====================
830 #`arctan##` (%`m##`)
831 : compute the inverse tangent (@`arctan`) of each cell of the matrix %`m##`.
832
833 ################################################################################
834 "`arctan2`"
835 © Paul Boersma 2023
836
837 A function that can be used in @@Formulas@. The argument angle.
838
839 Syntax and semantics
840 ====================
841 #`arctan2` (%`y`, %`x`)
842 : the angle (in radians) from the %X axis to the point (%x, %y) in two-dimensional space;
843 positive (i.e. measured counterclockwise) for %y > 0,
844 and negative (and measured clockwise) for %y < 0.
845 For %y = 0, it’s 0 if %x > 0, and %\pi if %x < 0.
846 In the point (0, 0), `arctan2` is undefined.
847
848 Tests
849 =====
850 {
851 \`{assert} \#{arctan2} (0.0, 3.0) = 0
852 \`{assert} \`{abs} (\#{arctan2} (3.0, 3.0) - pi/4) < 1e-17
853 \`{assert} \`{abs} (\#{arctan2} (3.0, 0.0) - pi/2) < 1e-17
854 \`{assert} \`{abs} (\#{arctan2} (3.0, -3.0) - 3*pi/4) < 1e-17
855 \`{assert} \`{abs} (\#{arctan2} (0.0, -3.0) - pi) < 1e-17
856 \`{assert} \`{abs} (\#{arctan2} (-3.0, -3.0) + 3*pi/4) < 1e-17
857 \`{assert} \`{abs} (\#{arctan2} (-3.0, 0.0) + pi/2) < 1e-17
858 \`{assert} \`{abs} (\#{arctan2} (-3.0, 3.0) + pi/4) < 1e-17
859 ;\`{assert} \#{arctan2} (0.0, 0.0) = undefined
860 }
861 Edge cases
862 ==========
863 In C, and therefore in Numpy, `arctan2` has arbitrary values
864 where it cannot be defined. Thus `numpy.arctan2 (0.0, +0.0)` is 0,
865 `numpy.arctan2 (+0.0, -0.0)` is +%\pi,
866 and `numpy.arctan2 (-0.0, -0.0)` is \-m%\pi.
867 The function is then even defined for e.g. %x = \-m∞ and %y = +∞,
868 where it is 3%\pi/4. In all these cases, `arctan` returns `undefined` in Praat.
869 This doesn’t mean that the function is very sane in Praat, as
870 it is still discontinuous for small %`y`:
871 {
872 writeInfoLine: \#{arctan2} (1e-308, -1.0), " ", \#{arctan2} (-1e-308, -1.0)
873 }
874 which are indistinguishable from +%\pi and \-m%\pi, respectively.
875
876 ################################################################################
877 "`arctanh`"
878 © Paul Boersma 2023
879
880 A function that can be used in @@Formulas@.
881
882 Syntax and semantics
883 ====================
884 #`arctanh` (%`x`)
885 : compute the inverse hyperbolic tangent of %`x`.
886
887 Tests
888 =====
889 {
890 \`{assert} \#{arctanh} (-1.0) = undefined
891 \`{assert} \#{arctanh} (0.0) = 0
892 \`{assert} \#{arctanh} (1.0) = undefined
893 \`{assert} \#{arctanh} (1000) = undefined
894 \`{assert} \#{arctanh} (undefined) = undefined
895 }
896
897 ################################################################################
898 "`arctanh#`"
899 © Paul Boersma 2023
900
901 A function that can be used in @@Formulas@.
902
903 #`arctanh#` (%`v#`)
904 : compute the inverse hyperbolic tangent (@`arctanh`) of each element of the vector %`v#`.
905
906 ################################################################################
907 "`arctanh##`"
908 © Paul Boersma 2023
909
910 A function that can be used in @@Formulas@.
911
912 Syntax and semantics
913 ====================
914 #`arctanh##` (%`m##`)
915 : compute the inverse hyperbolic tangent (@`arctanh`) of each cell of the matrix %`m##`.
916
917 ################################################################################
918 "`assert`"
919 © Paul Boersma 2023
920
921 A keyword that can be used in @Scripting, to test whether an expected condition holds.
922
923 Examples
924 ========
925
926 This is an assertion that is satisfied:
927 {
928 a = 5*6
929 \#{assert} a = 30
930 writeInfoLine: a
931 }
932 This is an assertion that is violated:
933 {;
934 a = 5*6
935 \#{assert} a < 10
936 writeInfoLine: a
937 }
938 This three-line script stops at the second line with the error message
939 “`Assertion violated in line 2: a < 10`”.
940
941 That is, because %`a` is not less than 10 (it’s 30),
942 the assertion is false, and the script stops, mentioning the line number
943 as well as the text of the assertion (i.e. “`a < 10`”).
944
945 ################################################################################
946 "`asserterror`"
947 © Paul Boersma 2023,2026
948
949 A keyword that can be used in @Scripting, to test whether an expected error message is indeed generated.
950
951 Examples
952 ========
953
954 {
955 \#{asserterror} Unknown variable
956 a = 2 * b + 3
957 }
958 The line `a = 2 * b + 3` contains the unknown variable `b`. Therefore, the script would normally issue an error message like
959 `
960 Unknown variable:
961 « a = 2 * b
962
963 Script line 2 not performed or completed:
964 « a = 2 * b + 3 »
965 Menu command “Run” not completed.
966 `
967 The line with #`asserterror` prevents the error message from being popped up, and instead checks
968 that the error message contains the string “Unknown variable”, which it does.
969
970 This one works differently:
971 {;
972 b = 4
973 \#{asserterror} Unknown variable
974 a = 2 * b + 3
975 }
976 In this case the expected error message does not occur, and the script exits with the following error message:
977 `
978 Script assertion fails in line 2: error « Unknown variable » not raised.
979 Instead: no error.
980
981 Script line 3 not performed or completed:
982 « a = 2 * b + 3 »
983 Menu command “Run” not completed.
984 `
985 Another case:
986 {;
987 \#{asserterror} What is blabla
988 a = Create Sound from blabla: 1, 2, 3
989 }
990 In this case a different error message than the expected error message occurs, and the script exits with the following error message:
991 `
992 Script assertion fails in line 1: error « What is blabla » not raised.
993 Instead: Command “Create Sound from blabla:” not available for current selection.
994
995 Script line 2 not performed or completed:
996 « a = Create Sound from blabla: 1, 2, 3 »
997 Menu command “Run” not completed.
998 `
999
1000 ################################################################################
1001 "`asynchronous`"
1002 © Paul Boersma 2023,2026
1003
1004 A keyword that can be used in @Scripting, to let a script continue while a sound is playing:
1005 {;
1006 \#{asynchronous} \@{Sound: ||Play}
1007 }
1008 or to let a script continue while a subprocess is running:
1009 {;
1010 \#{asynchronous} \`{runSubprocess}: “C://apps/videoViewer.exe”, “hello.wav”
1011 }
1012 or
1013 {;
1014 \#{asynchronous} \`{runSystem}: “C://apps/videoViewer.exe hello.wav”
1015 }
1016
1017 ################################################################################
1018 "`backslashTrigraphsToUnicode$`"
1019 © Paul Boersma 2023
1020
1021 A function that can be used in @Formulas.
1022
1023 Syntax and semantics
1024 ====================
1025 #`backslashTrigraphsToUnicode$` (%`string$`)
1026 : convert from backslash trigraphs to unicode characters,
1027 e.g. from “\bsct” to “\ct”.
1028
1029 ################################################################################
1030 "`barkToHertz`"
1031 © Paul Boersma 2023
1032
1033 A function that can be used in @Formulas.
1034
1035 Syntax and semantics
1036 ====================
1037 #`barkToHertz` (%`x`)
1038 : convert from an auditory Bark-rate value %`x` to an acoustic frequency in Hz.
1039
1040 Definition
1041 ==========
1042 ~ #`barkToHertz` (%x) = 650 @`sinh` (%x / 7)
1043
1044 ################################################################################
1045 "`besselI`"
1046 © Paul Boersma 2023
1047
1048 A function that can be used in @Formulas.
1049
1050 Syntax and semantics
1051 ====================
1052 #`besselI` (%`n`, %`x`)
1053 : compute the %`n`th modified Bessel function of the first kind (%I_%`n`) of %`x`.
1054
1055 ################################################################################
1056 "`besselK`"
1057 © Paul Boersma 2023
1058
1059 A function that can be used in @Formulas.
1060
1061 Syntax and semantics
1062 ====================
1063 #`besselK` (%`n`, %`x`)
1064 : compute the %`n`th modified Bessel function of the second kind (%K_%`n`) of %`x`.
1065
1066 ################################################################################
1067 "`beta`"
1068 © Paul Boersma 2023
1069
1070 A function that can be used in @Formulas.
1071
1072 Syntax and semantics
1073 ====================
1074 #`beta` (%`x`, %`y`)
1075 : compute the %\be function.
1076
1077 ################################################################################
1078 "`between_by#`"
1079 © Paul Boersma 2023
1080
1081 A function that can be used in @Formulas.
1082
1083 Syntax and semantics
1084 ====================
1085 #`between_by#` (%`low`, %`high`, %`step`)
1086 : compute symmetrically dispersed numbers between %`low` and %`high`, in steps of %`step`.
1087
1088 ################################################################################
1089 "`between_count#`"
1090 © Paul Boersma 2023
1091
1092 A function that can be used in @Formulas.
1093
1094 Syntax and semantics
1095 ====================
1096 #`between_count#` (%`low`, %`high`, %`n`)
1097 : compute %`n` symmetrically dispersed numbers between %`low` and %`high` (bin centres).
1098
1099 ################################################################################
1100 "`binomialP`"
1101 © Paul Boersma 2023
1102
1103 A function that can be used in @@Formulas@. The cumulative binomial distribution.
1104
1105 Syntax and semantics
1106 ====================
1107 #`binomialP` (%`p`, %`k`, %`n`)
1108 : compute the probability that in %`n` trials an event with probability %`p` will occur at most %`k` times.
1109
1110 Related function
1111 ================
1112 It is probably more common to use the complement of this function, namely @`binomialQ`.
1113
1114 ################################################################################
1115 "`binomialQ`"
1116 © Paul Boersma 2014, 2023
1117
1118 A function that can be used in @@Formulas@. The complement of the cumulative binomial distribution.
1119
1120 Syntax and semantics
1121 ====================
1122 #`binomialQ` (%`p`, %`k`, %`n`)
1123 : compute the probability that in %`n` trials an event with probability %`p` will occur at least %`k` times.
1124
1125 Calculator example
1126 ==================
1127
1128 A die is suspected to yield more sixes than a perfect die would do. In order to test this suspicion,
1129 you throw it 1,000 times. The result is 211 sixes.
1130
1131 The probability that a perfect die yields at least 211 sixes is, according to @@Calculator...@,
1132 {
1133 appendInfoLine: \#{binomialQ} (1/6, 211, 1000)
1134 }
1135 which should be 0.000152.
1136
1137 Script example
1138 ==============
1139
1140 You convert 1000 values of pitch targets in Hz to the nearest note on the piano keyboard.
1141 597 of those values turn out to be in the A, B, C, D, E, F, or G regions (the white keys), and 403 values turn out
1142 to be in the A\# , C\# , D\# , F\# , or G\# regions (the black keys).
1143 Do our subjects have a preference for the white keys?
1144 The following script computes the probability that in the case of no preference the subjects
1145 would target the white keys at least 597 times. This is compared with a %\ci^2 test.
1146 {
1147 a = 597
1148 b = 403
1149 p = 7/12 ; no preference
1150 writeInfoLine: “*** Binomial test ”, a, “, ”, b, “, p = ”, fixed$ (p, 6), “ ***”
1151 pbin = \#{binomialQ} (p, a, a+b)
1152 appendInfoLine: “P (binomial) = ”, fixed$ (pbin, 6)
1153 # Chi-square test with Yates correction:
1154 x2 = (a - 1/2 - p * (a+b)) ^ 2 / ( p * (a+b)) +
1155 ... (b + 1/2 - (1-p) * (a+b)) ^ 2 / ((1-p) * (a+b))
1156 px2 = chiSquareQ (x2, 1)
1157 appendInfoLine: “P (chi-square) = ”, fixed$ (px2, 6)
1158 }
1159 The result is:
1160 `
1161 *** Binomial test 597, 403, p = 0.583333 ***
1162 P (binomial) = 0.199330
1163 P (chi-square) = 0.398365
1164 `
1165 The %\ci^2 test is two-sided (it signals a preference for the white or for the black keys),
1166 so it has twice the probability of the binomial test.
1167
1168 We cannot conclude from this test that people have a preference for the white keys.
1169 Of course, we cannot conclude either that people %%don’t% have such a preference.
1170
1171 ################################################################################
1172 "`ceiling`"
1173 © Paul Boersma 2023
1174
1175 A function that can be used in @@Formulas@.
1176
1177 Syntax and semantics
1178 ====================
1179 #`ceiling` (%`x`)
1180 : round %`x` up to the nearest integer number.
1181
1182 ################################################################################
1183 "`ceiling#`"
1184 © Paul Boersma 2023
1185
1186 A function that can be used in @@Formulas@.
1187
1188 Syntax and semantics
1189 ====================
1190 #`ceiling#` (%`v#`)
1191 : round up (@`ceiling`) each element of the vector %`v#`.
1192
1193 ################################################################################
1194 "`ceiling##`"
1195 © Paul Boersma 2023
1196
1197 A function that can be used in @@Formulas@.
1198
1199 Syntax and semantics
1200 ====================
1201 #`ceiling##` (%`m##`)
1202 : round up (@`ceiling`) each cell of the matrix %`m##`.
1203
1204 ################################################################################
1205 "`center`"
1206 © Paul Boersma 2023
1207
1208 A function that can be used in @@Formulas@.
1209
1210 Syntax and semantics
1211 ====================
1212 #`center` (%`v#`)
1213 : compute the center (or centre) of gravity of the vector %`v#`.
1214
1215 ################################################################################
1216 "`chiSquareP`"
1217 © Paul Boersma 2023
1218
1219 A function that can be used in @@Formulas@.
1220
1221 Syntax and semantics
1222 ====================
1223 #`chiSquareP` (%`chiSquare`, %`df`)
1224 : compute the area under the %\ci^2 distribution between 0 and %`chiSquare`,
1225 for %`df` degrees of freedom.
1226
1227 ################################################################################
1228 "`chiSquareQ`"
1229 © Paul Boersma 2023
1230
1231 A function that can be used in @@Formulas@.
1232
1233 Syntax and semantics
1234 ====================
1235 #`chiSquareQ` (%`chiSquare`, %`df`)
1236 : compute the area under the %\ci^2 curve between %`chiSquare` and +\oo,
1237 for %`df` degrees of freedom, i.e. the “statistical significance %p”
1238 of the %\ci^2 difference between two distributions in %`df`+1 dimensions.
1239
1240 ################################################################################
1241 "`chooseFolder$`"
1242 © Paul Boersma 2023
1243
1244 A function that can be used in @Scripting.
1245
1246 Syntax and semantics
1247 ====================
1248 #`chooseFolder$` (%`title$`)
1249 : pop up a folder selection window.
1250
1251 ################################################################################
1252 "`chooseReadFile$`"
1253 © Paul Boersma 2023
1254
1255 A function that can be used in @Scripting.
1256
1257 Syntax and semantics
1258 ====================
1259 #`chooseReadFile$` (%`title$`)
1260 : pop up a file selection window for opening (or appending to) an existing file.
1261
1262 ################################################################################
1263 "`chooseWriteFile$`"
1264 © Paul Boersma 2023
1265
1266 A function that can be used in @Scripting.
1267
1268 Syntax and semantics
1269 ====================
1270 #`chooseWriteFile$` (%`title$`, %`defaultFilename$`)
1271 : pop up a file selection window for saving to a new file.
1272
1273 ################################################################################
1274 "`clearinfo`"
1275 © Paul Boersma 2023
1276
1277 A command that can be used in @Scripting.
1278
1279 Syntax and semantics
1280 ====================
1281 #`clearinfo`
1282 : clear the @@Info window@.
1283
1284 ################################################################################
1285 "`clock`"
1286 © Paul Boersma 2025
1287
1288 A function that can be used in @@Formulas@.
1289
1290 Syntax and semantics
1291 ====================
1292 #`clock` ( )
1293 : the number of seconds since system start-up, with microsecond precision.
1294
1295 Examples
1296 ========
1297 {
1298 t = \#{clock}()
1299 for i to 1000
1300 endfor
1301 \`{appendInfoLine}: "Time elapsed: ", \#{clock}() - t, " seconds"
1302 }
1303 {
1304 t = \#{clock}()
1305 for i to 1000
1306 endfor
1307 timeElapsed = \#{clock}() - t
1308 \`{appendInfoLine}: "Time elapsed: ", \`{fixed$} (1000 * timeElapsed, 3), " ms"
1309 }
1310
1311 ################################################################################
1312 "`col`"
1313 © Paul Boersma 2024
1314
1315 The column number (of the current cell) in a Formula command.
1316
1317 See @@Formulas 1.7. Formulas for modification@.
1318
1319 ################################################################################
1320 "`col$`"
1321 © Paul Boersma 2024
1322
1323 The name of a column of an object.
1324
1325 Syntax and semantics
1326 ====================
1327 #`col$` [%`i`]
1328 : the name of the %%i%th column of an object.
1329
1330 See @@Formulas 8. Attributes of objects@.
1331
1332 ################################################################################
1333 "`col#`"
1334 © Paul Boersma 2024
1335
1336 A function that can be used in @Formulas.
1337
1338 Syntax and semantics
1339 ====================
1340 #`col#` (%`m##`, %`i`)
1341 : extract the %`i`th column from the matrix %`m##`.
1342
1343 Examples
1344 ========
1345 {
1346 mat## = {{ 7, 4 }, { 99, 103 }}
1347 \`{assert} col# (mat##, 2) = { 4, 103 }
1348 }
1349
1350 ################################################################################
1351 "`columnSums#`"
1352 © Paul Boersma 2023
1353
1354 A function that can be used in @Formulas.
1355
1356 Syntax and semantics
1357 ====================
1358 #`columnSums#` (%`m##`)
1359 : compute the sum of the elements of each row of the matrix %`m##`.
1360
1361 ################################################################################
1362 "`combine#`"
1363 © Paul Boersma 2023
1364
1365 A function that can be used in @Formulas.
1366
1367 Syntax and semantics
1368 ====================
1369 #`combine#` (...)
1370 : combine numbers, vectors and matrices into a new vector.
1371
1372 Examples
1373 ========
1374 {
1375 \`{assert} \#{combine#} (7, 4, 99) = { 7, 4, 99 }
1376 \`{assert} \#{combine#} ({ 7, 4 }, 99) = { 7, 4, 99 }
1377 \`{assert} \#{combine#} ({ 7, 4 }, { 99, 103, 1 }) = { 7, 4, 99, 103, 1 }
1378 \`{assert} \#{combine#} ({{ 7, 4 }, { 99, 103 }}, 1, { 8, -1, 2 }) =
1379 ... { 7, 4, 99, 103, 1, 8, -1, 2 }
1380 }
1381
1382 ################################################################################
1383 "`correlation`"
1384 © Paul Boersma 2023
1385
1386 A function that can be used in @Formulas.
1387
1388 Syntax and semantics
1389 ====================
1390 #`correlation` (%`u#`, %`v#`)
1391 : compute the correlation between the vectors %`u#` and %`v#`.
1392
1393 Precondition
1394 ============
1395 The vectors %`u#` and %`v#` have to have equal numbers of elements.
1396
1397 Definition
1398 ==========
1399 If %N is the number of elements of both #u and #v,
1400 ~ %m_%u = (1/%N) \su__%i=1_^%N %u_%i
1401 ~ %m_%v = (1/%N) \su__%i=1_^%N %v_%i
1402 ~ %ssq_%u = \su__%i=1_^%N (%u_%i \-m %m_%u)^2
1403 ~ %ssq_%v = \su__%i=1_^%N (%v_%i \-m %m_%v)^2
1404 ~ `correlation` (#u, #v) = \su__%i=1_^%N (%u_%i \-m %m_%u) · (%v_%i \-m %m_%v) /
1405 \Vr(%ssq_%u · %ssq_%v)
1406
1407 ################################################################################
1408 "`cos`"
1409 © Paul Boersma 2023
1410
1411 A function that can be used in @@Formulas@.
1412
1413 Syntax and semantics
1414 ====================
1415 #`cos` (%`x`)
1416 : compute the cosine of %`x`.
1417 {
1418 Axes: -5, 5, -1.1, 1.1
1419 Draw inner box
1420 Draw function: -5, 5, 1000, ~ \#{cos} (x)
1421 One mark bottom: -3*pi/2, "no", "yes", "yes", "\-m3%\pi/2"
1422 One mark bottom: -pi, "no", "yes", "yes", "\-m%\pi"
1423 One mark bottom: -pi/2, "no", "yes", "yes", "\-m%\pi/2"
1424 One mark bottom: 0, "no", "yes", "yes", "0"
1425 One mark bottom: pi/2, "no", "yes", "yes", "+%\pi/2"
1426 One mark bottom: pi, "no", "yes", "yes", "+%\pi"
1427 One mark bottom: 3*pi/2, "no", "yes", "yes", "+3%\pi/2"
1428 One mark left: -1, "no", "yes", "yes", "\-m1"
1429 One mark left: 0, "no", "yes", "yes", "0"
1430 One mark left: 1, "no", "yes", "yes", "+1"
1431 Text bottom: "yes", "%x \->"
1432 Text left: "yes", "##\#{cos}# (%x)"
1433 Text top: "no", "##just over one and a half periods of a (co)sine wave"
1434 }
1435 This picture illustrates the following properties of the cosine function:
1436
1437 - #`cos` (%x) is zero for all values of %x that are odd multiples of %\pi/2.
1438 - The extrema of #`cos` (%x) are \-m1 and +1.
1439 - #`cos` (%x) is \-m1 or +1 wherever %x is an integer multiple of %\pi.
1440 - The cosine function is %periodic with period 2%\pi, i.e., #`cos` (%x+2%\pi) = #`cos` (%x).
1441 - The cosine function is %symmetric around 0, i.e. #`cos` (\-m%x) = #`cos` (%x).
1442 - The cosine function is %antisymmetric around %\pi/2, i.e. #`cos` (%\pi/2\-m%x) = \-m #`cos` (%x);
1443 in other words, if you take the cosine curve and rotate it by 180 degrees
1444 around the point (%\pi/2, 0), then you get the same curve again.
1445
1446 A cosine wave is a special case of the more general %%sine wave% that is given by
1447 %y = @`sin` (%x + %\fi), where %\fi (an additive constant called the %%initial phase%) is %\pi/2.
1448
1449 ################################################################################
1450 "`cos#`"
1451 © Paul Boersma 2023
1452
1453 A function that can be used in @@Formulas@.
1454
1455 Syntax and semantics
1456 ====================
1457 #`cos#` (%`v#`)
1458 : compute the cosine (@`cos`) of each element of the vector %`v#`.
1459
1460 ################################################################################
1461 "`cos##`"
1462 © Paul Boersma 2023
1463
1464 A function that can be used in @@Formulas@.
1465
1466 Syntax and semantics
1467 ====================
1468 #`cos##` (%`m##`)
1469 : compute the cosine (@`cos`) of each cell of the matrix %`m##`.
1470
1471 ################################################################################
1472 "`cosh`"
1473 © Paul Boersma 2023
1474
1475 A function that can be used in @@Formulas@.
1476
1477 Syntax and semantics
1478 ====================
1479 #`cosh` (%`x`)
1480 : compute the hyperbolic cosine of %`x`, i.e. (%e^%x + %e^^-%x^) / 2.
1481
1482 ################################################################################
1483 "`cosh#`"
1484 © Paul Boersma 2023
1485
1486 A function that can be used in @@Formulas@.
1487
1488 Syntax and semantics
1489 ====================
1490 #`cosh#` (%`v#`)
1491 : compute the hyperbolic cosine (@`cosh`) of each element of the vector %`v#`.
1492
1493 ################################################################################
1494 "`cosh##`"
1495 © Paul Boersma 2023
1496
1497 A function that can be used in @@Formulas@.
1498
1499 Syntax and semantics
1500 ====================
1501 #`cosh##` (%`m##`)
1502 : compute the hyperbolic cosine (@`cosh`) of each cell of the matrix %`m##`.
1503
1504 ################################################################################
1505 "`createFolder`"
1506 © Paul Boersma 2023
1507
1508 A function that can be used in @Scripting.
1509
1510 Syntax and semantics
1511 ====================
1512 #`createFolder` (%`folderPath$`)
1513 : create a new folder, or do nothing if the folder already exists.
1514
1515 ################################################################################
1516 "`date$`"
1517 © Paul Boersma 2003,2023
1518
1519 A function that can be used in @Formulas.
1520
1521 Syntax and semantics
1522 ====================
1523 #`date$` ( )
1524 : format the current local date and time in a human-readable format.
1525 {
1526 writeInfoLine: date$ ()
1527 }
1528
1529 ################################################################################
1530 "`date_iso$`"
1531 © Paul Boersma 2021,2023
1532
1533 A function that can be used in @Formulas.
1534
1535 Syntax and semantics
1536 ====================
1537 #`date_iso$` ( )
1538 : format the current local date and time in ISO 8601 format.
1539 {
1540 writeInfoLine: date_iso$ ()
1541 }
1542
1543 ################################################################################
1544 "`date#`"
1545 © Paul Boersma 2021,2023
1546
1547 A function that can be used in @Formulas.
1548
1549 Syntax and semantics
1550 ====================
1551 #`date#` ( )
1552 : format the current local date and time as a 6-element vector containing
1553 the year, the month number, the day, the hours, the minutes, and the seconds.
1554 {
1555 writeInfoLine: date# ()
1556 }
1557
1558 ################################################################################
1559 "`date_utc$`"
1560 © Paul Boersma 2021,2023
1561
1562 A function that can be used in @Formulas.
1563
1564 Syntax and semantics
1565 ====================
1566 #`date_utc$` ( )
1567 : format the current Coordinated Universal Time in a human-readable format.
1568 {
1569 writeInfoLine: date_utc$ ()
1570 }
1571
1572 ################################################################################
1573 "`date_utc_iso$`"
1574 © Paul Boersma 2021,2023
1575
1576 A function that can be used in @Formulas.
1577
1578 Syntax and semantics
1579 ====================
1580 #`date_utc_iso$` ( )
1581 : format the current Coordinated Universal Time in a ISO 8601 format.
1582 {
1583 writeInfoLine: date_utc_iso$ ()
1584 }
1585
1586 ################################################################################
1587 "`date_utc#`"
1588 © Paul Boersma 2021,2023
1589
1590 A function that can be used in @Formulas.
1591
1592 Syntax and semantics
1593 ====================
1594 #`date#` ( )
1595 : format the current Coordinated Universal Time as a 6-element vector containing
1596 the year, the month number, the day, the hours, the minutes, and the seconds.
1597 {
1598 writeInfoLine: date_utc# ()
1599 }
1600
1601 ################################################################################
1602 "`deleteFile`"
1603 © Paul Boersma 2023
1604
1605 A function that can be used in @Scripting.
1606
1607 Syntax and semantics
1608 ====================
1609 #`deleteFile` (%`filePath$`)
1610 : delete a file, or do nothing if the file does not exist.
1611
1612 ################################################################################
1613 "`demo`"
1614 © Paul Boersma 2023
1615
1616 A keyword that can be used in @Scripting,
1617 for executing a graphics command in the Demo window (instead of in the Picture window).
1618
1619 Example
1620 =======
1621 The following code draws a box into the Picture window:
1622 {
1623 \@{Erase all}
1624 \@{Draw inner box}
1625 }
1626 The following code draws a box into the Demo window instead:
1627 {;
1628 \#{demo} \@{Erase all}
1629 \#{demo} \@{Draw inner box}
1630 }
1631
1632 More examples
1633 =============
1634
1635 ################################################################################
1636 "`demoClicked`"
1637 © Paul Boersma 2023
1638
1639 A function that can be used in @Scripting.
1640
1641 Syntax and semantics
1642 ====================
1643 #`demoClicked` ( )
1644 : determine whether the user clicked in the Demo window.
1645
1646 Usage
1647 =====
1648 This function is usually called after a user event has been detected (with @`demoWaitForInput`),
1649 and is typically followed by determining the location of the click
1650 (with @`demoX`) and @`demoY`, or with @`demoClickedIn`).
1651
1652 ################################################################################
1653 "`demoClickedIn`"
1654 © Paul Boersma 2023
1655
1656 A function that can be used in @Scripting.
1657
1658 Syntax and semantics
1659 ====================
1660 #`demoClickedIn` (%`xmin`, %`xmax`, %`ymmin`, %`ymax`)
1661 : determine whether the user clicked in a rectangular region in the Demo window.
1662
1663 Usage
1664 =====
1665 This function is usually called after it has been determined that the user clicked into the Demo window,
1666 i.e. after @`demoClicked` has returned 1.
1667
1668 ################################################################################
1669 "`demoCommandKeyPressed`"
1670 © Paul Boersma 2023
1671
1672 A function that can be used in @Scripting.
1673
1674 Syntax and semantics
1675 ====================
1676 #`demoCommandKeyPressed` ( )
1677 : determine whether the user pressed the Command key when they typed into the Demo window.
1678
1679 Usage
1680 =====
1681 This function is usually called after it has been determined that the user pressed a key,
1682 i.e. after @`demoKeyPressed` has returned 1.
1683
1684 ################################################################################
1685 "`demoInput`"
1686 © Paul Boersma 2023
1687
1688 A function that can be used in @Scripting.
1689
1690 Syntax and semantics
1691 ====================
1692 #`demoInput` (%`characters$`)
1693 : determine whether the user typed (or clicked) the specified characters into the Demo window.
1694
1695 ################################################################################
1696 "`demoKey$`"
1697 © Paul Boersma 2023
1698
1699 A function that can be used in @Scripting.
1700
1701 Syntax and semantics
1702 ====================
1703 #`demoKey$` ( )
1704 : determine the key that the user typed into the Demo window.
1705
1706 ################################################################################
1707 "`demoKeyPressed`"
1708 © Paul Boersma 2023
1709
1710 A function that can be used in @Scripting.
1711
1712 Syntax and semantics
1713 ====================
1714 #`demoKeyPressed` ( )
1715 : determine whether the user typed anything into the Demo window.
1716
1717 Usage
1718 =====
1719 This function is usually called after a user event has been detected (with @`demoWaitForInput`),
1720 and is typically followed by determining the key that was pressed
1721 (with @`demoKey$`), perhaps while determining which modifier keys were pressed
1722 (with @`demoShiftKeyPressed`, @`demoOptionKeyPressed`, and/or @`demoCommandKeyPressed`).
1723
1724 ################################################################################
1725 "`demoShow`"
1726 © Paul Boersma 2023
1727
1728 A function that can be used in @Scripting.
1729
1730 Syntax and semantics
1731 ====================
1732 #`demoShow` ( )
1733 : make all deferred drawing commands immediately visible.
1734
1735 Usage
1736 =====
1737 This function is used in animation, where you cannot wait until @`demoWaitForInput`
1738 causes the drawings to become visible.
1739
1740 ################################################################################
1741 "`demoOptionKeyPressed`"
1742 © Paul Boersma 2023
1743
1744 A function that can be used in @Scripting.
1745
1746 Syntax and semantics
1747 ====================
1748 #`demoOptionKeyPressed` ( )
1749 : determine whether the user pressed the Option key when they typed into the Demo window.
1750
1751 Usage
1752 =====
1753 This function is usually called after it has been determined that the user pressed a key,
1754 i.e. after @`demoKeyPressed` has returned 1.
1755
1756 ################################################################################
1757 "`demoPeekInput`"
1758 © Paul Boersma 2023
1759
1760 A function that can be used in @Scripting.
1761
1762 Syntax and semantics
1763 ====================
1764 #`demoPeekInput` ( )
1765 : see whether a user event (click or key press) is available in the Demo window.
1766
1767 ################################################################################
1768 "`demoShiftKeyPressed`"
1769 © Paul Boersma 2023
1770
1771 A function that can be used in @Scripting.
1772
1773 Syntax and semantics
1774 ====================
1775 #`demoShiftKeyPressed` ( )
1776 : determine whether the user pressed the Shift key when they typed into the Demo window.
1777
1778 Usage
1779 =====
1780 This function is usually called after it has been determined that the user pressed a key,
1781 i.e. after @`demoKeyPressed` has returned 1.
1782
1783 ################################################################################
1784 "`demoWaitForInput`"
1785 © Paul Boersma 2023
1786
1787 A function that can be used in @Scripting.
1788
1789 Syntax and semantics
1790 ====================
1791 #`demoWaitForInput` ( )
1792 : wait for a user event (click or key press) in the Demo window.
1793
1794 Behaviour
1795 =========
1796 This function blocks until the user clicks in the Demo window or types a key into the Demo window.
1797
1798 Return value
1799 ============
1800 Once the function finally returns, it returns the value 1 (true).
1801 This makes it possible to use this function in a `while` loop:
1802 {;
1803 while \#`{demoWaitForInput} ()
1804 if \`{demoClicked} ())
1805 # handle the mouse click
1806 elsif \`{demoKeyPressed} ())
1807 # handle the key press
1808 endif
1809 endwhile
1810 }
1811
1812 ################################################################################
1813 "`demoWindowTitle`"
1814 © Paul Boersma 2023
1815
1816 A function that can be used in @Scripting.
1817
1818 Syntax and semantics
1819 ====================
1820 #`demoWindowTitle` (%`newTitle$`)
1821 : change the title of the Demo window to %`newTitle$`.
1822
1823 ################################################################################
1824 "`demoX`"
1825 © Paul Boersma 2023
1826
1827 A function that can be used in @Scripting.
1828
1829 Syntax and semantics
1830 ====================
1831 #`demoX` ( )
1832 : the horizontal position of a mouse click in the Demo window.
1833
1834 ################################################################################
1835 "`demoY`"
1836 © Paul Boersma 2023
1837
1838 A function that can be used in @Scripting.
1839
1840 Syntax and semantics
1841 ====================
1842 #`demoY` ( )
1843 : the vertical position of a mouse click in the Demo window.
1844
1845 ################################################################################
1846 "`differenceLimensToPhon`"
1847 © Paul Boersma 2002,2023
1848
1849 A function that can be used in @Formulas.
1850
1851 Syntax and semantics
1852 ====================
1853 #`differenceLimensToPhon` (%`ndli`)
1854 : convert auditory intensity difference limens into a sensation level in phon units.
1855
1856 Definition
1857 ==========
1858 ~ #`differenceLimensToPhon` (%ndli) = @`ln` (1 + %ndli / 30) / @`ln` (61 / 60)
1859
1860 Related function
1861 ================
1862 #`differenceLimensToPhon` is the inverse of @`phonToDifferenceLimens`.
1863
1864 ################################################################################
1865 "`dx`"
1866 © Paul Boersma 2024
1867
1868 The horizontal distance between cells (i.e. the distance between columns) of an object,
1869 in world coordinates.
1870
1871 See @@Formulas 8. Attributes of objects@.
1872
1873 ################################################################################
1874 "`dy`"
1875 © Paul Boersma 2024
1876
1877 The vertical distance between cells (i.e. the distance between rows) of an object,
1878 in world coordinates.
1879
1880 See @@Formulas 8. Attributes of objects@.
1881
1882 ################################################################################
1883 "`editor`"
1884 © Paul Boersma 2023
1885
1886 A function that can be used in @Scripting.
1887
1888 Syntax and semantics
1889 ====================
1890 #`editor` (%`editorID`)
1891 : enter the environment of the editor whose ID is %`editorID`.
1892
1893 #`editor` (%`editorName$`)
1894 : enter the environment of the editor whose name is %`editorName$`.
1895
1896 For an introduction, see @@Scripting 7. Scripting the editors@.
1897
1898 ################################################################################
1899 "`empty$#`"
1900 © Paul Boersma 2002, 2023
1901
1902 A function that can be used in @Formulas.
1903
1904 Syntax and semantics
1905 ====================
1906 #`empty$#` (%`numberOfStrings`)
1907 : create an array of empty strings.
1908
1909 ################################################################################
1910 "`endeditor`"
1911 © Paul Boersma 2023
1912
1913 A function that can be used in @Scripting.
1914
1915 Syntax and semantics
1916 ====================
1917 #`endeditor`
1918 : leave the environment of the current editor switching back to the @@List of Objects@.
1919
1920 For an introduction, see @@Scripting 7. Scripting the editors@.
1921
1922 ################################################################################
1923 "`endproc`"
1924 © Paul Boersma 2023
1925
1926 A keyword that can be used in @Scripting.
1927
1928 Syntax and semantics
1929 ====================
1930 #`endproc`
1931 : finish the definition of a procedure.
1932
1933 For an introduction, see @@Scripting 5.5. Procedures@.
1934
1935 ################################################################################
1936 "`endsWith`"
1937 © Paul Boersma 2023
1938
1939 A function that can be used in @@Formulas@.
1940
1941 Syntax and semantics
1942 ====================
1943 #`endsWith` (%`string$`, %`part$`)
1944 : determine whether %`string$` ends in %`part$`.
1945
1946 See also
1947 ========
1948 - @`startsWith` for determining whether %`string$` %starts with %`part$`.
1949 - @`endsWith_caseInsensitive` for %%case-insensitive% matching.
1950
1951 ################################################################################
1952 "`endsWith_caseInsensitive`"
1953 © Paul Boersma 2023
1954
1955 A function that can be used in @@Formulas@.
1956
1957 Syntax and semantics
1958 ====================
1959 #`endsWith_caseInsensitive` (%`string$`, %`part$`)
1960 : determine whether %`string$` ends in %`part$`.
1961
1962 See also
1963 ========
1964 - @`startsWith_caseInsensitive` for determining whether %`string$` %starts with %`part$`.
1965 - @`endsWith` for %%case-sensitive% matching.
1966
1967 ################################################################################
1968 "`environment$`"
1969 © Paul Boersma 2023
1970
1971 A function that can be used in @@Formulas@.
1972
1973 Syntax and semantics
1974 ====================
1975 #`environment$` (%`string$`)
1976 : look up a system environment string.
1977
1978 For details and examples, see @@Scripting 6.5. Calling system commands@.
1979
1980 ################################################################################
1981 "`erb`"
1982 © Paul Boersma 2023
1983
1984 A function that can be used in @@Formulas@.
1985
1986 Syntax and semantics
1987 ====================
1988 #`erb` (%`f`)
1989 : compute the auditory %%equivalent rectangular bandwidth% (ERB) in hertz,
1990 for a specified acoustic frequency %f (also in hertz).
1991
1992 Definition
1993 ==========
1994 ~ #`erb` (%f) = 6.23\.c10^^\-m6^ %f^2 + 0.09339 %f + 28.52
1995
1996 ################################################################################
1997 "`erbToHertz`"
1998 © Paul Boersma 2023
1999
2000 A function that can be used in @@Formulas@.
2001
2002 Syntax and semantics
2003 ====================
2004 #`erbToHertz` (%`x`)
2005 : convert from an auditory ERB-rate %`x` to an acoustic frequency in Hz.
2006
2007 Definition
2008 ==========
2009 ~ #`erbToHertz` (%x) (14680 %d - 312) / (1 - %d), where %d = exp ((%x - 43) / 11.17)
2010
2011 ################################################################################
2012 "`erf`"
2013 © Paul Boersma 2023
2014
2015 A function that can be used in @@Formulas@.
2016
2017 Syntax and semantics
2018 ====================
2019 #`erf` (%`x`)
2020 : compute the “error function”, the integral of the Gaussian, i.e.
2021
2022 Definition
2023 ==========
2024 ~ #`erf` (%x) = 2/\Vr%\pi _0\in^%x exp(-%t^2) %dt
2025
2026 Related function
2027 ================
2028 The complement of #`erf` is @`erfc`.
2029
2030 ################################################################################
2031 "`erfc`"
2032 © Paul Boersma 2023
2033
2034 A function that can be used in @@Formulas@.
2035
2036 Syntax and semantics
2037 ====================
2038 #`erfc` (%`x`)
2039 : compute the complement of the error function
2040
2041 Definition
2042 ==========
2043 #`erfc` (%x) = 1 − @`erf` (%x)
2044
2045 Why isn’t this function superfluous?
2046 ====================================
2047 Because of floating-point rounding errors:
2048 although one might think that @`erf` ic sufficient,
2049 #`erfc` is a separate function because @`erf` (%`x`) can be close to 1.
2050
2051 ################################################################################
2052 "`exitScript`"
2053 © Paul Boersma 2023
2054
2055 A function that can be used in @Scripting.
2056
2057 Syntax and semantics
2058 ====================
2059 #`exitScript` (`...`)
2060 : show a simple window message that tells the user why the script will be interrupted.
2061
2062 When the user clicks OK in this window, the script will have stopped running.
2063
2064 For details and examples, see @@Scripting 5.9. Quitting@
2065 and @@Scripting 6.8. Messages to the user@.
2066
2067 ################################################################################
2068 "`exp`"
2069 © Paul Boersma 2023
2070
2071 A function that can be used in @@Formulas@.
2072
2073 Syntax and semantics
2074 ====================
2075 #`exp` (%`x`)
2076 : exponentiate %x, i.e. compute %e^%`x`.
2077
2078 Related function
2079 ================
2080 The inverse of #`exp` is @`ln`.
2081
2082 ################################################################################
2083 "`exp#`"
2084 © Paul Boersma 2023
2085
2086 A function that can be used in @@Formulas@.
2087
2088 Syntax and semantics
2089 ====================
2090 #`exp#` (%`v#`)
2091 : exponentiate (@`exp`) each element of the vector %`v#`.
2092
2093 ################################################################################
2094 "`exp##`"
2095 © Paul Boersma 2023
2096
2097 A function that can be used in @@Formulas@.
2098
2099 Syntax and semantics
2100 ====================
2101 #`exp##` (%`m##`)
2102 : exponentiate (@`exp`) each cell of the matrix %`m##`.
2103
2104 ################################################################################
2105 "`extractLine$`"
2106 © Paul Boersma 2023
2107
2108 A function that can be used in @@Formulas@.
2109
2110 Syntax and semantics
2111 ====================
2112 #`extractLine$` (%`string$`, %`part$`)
2113 : return everything that comes after the first occurrence of %`part$` in %`string$`.
2114
2115 ################################################################################
2116 "`extractNumber`"
2117 © Paul Boersma 2023
2118
2119 A function that can be used in @@Formulas@.
2120
2121 Syntax and semantics
2122 ====================
2123 #`extractNumber` (%`string$`, %`part$`)
2124 : return the first number after the first occurrence of %`part$% in %`string$`.
2125
2126 ################################################################################
2127 "`extractWord$`"
2128 © Paul Boersma 2023
2129
2130 A function that can be used in @@Formulas@.
2131
2132 Syntax and semantics
2133 ====================
2134 #`extractWord$` (%`string$`, %`part$`)
2135 : return the first “word” after the first occurrence of %`part$% in %`string$`.
2136
2137 ################################################################################
2138 "`fileNames$#`"
2139 © Paul Boersma 2023,2025
2140
2141 A function that can be used in @@Formulas@, especially in @Scripting.
2142
2143 Syntax and semantics
2144 ====================
2145 #`fileNames$#` (%`folderNameOrPattern$`)
2146 : return the names (not the whole paths) of the files in a folder
2147 or that match a file-name pattern with up to two asterisks.
2148
2149 Behaviour
2150 =========
2151 The resulting string array will contain an alphabetical list of file names (by naïve Unicode-sorting),
2152 without the preceding path through the folder structures. If there are no files that match the file path,
2153 the string array will contain 0 strings.
2154
2155 Usage
2156 =====
2157 There are two ways to specify the file path.
2158
2159 One way is to specify a folder name only. On Unix, the file path could be
2160 `/usr/people/miep/sounds` or `/usr/people/miep/sounds/`, for instance. On Windows,
2161 `C:\Users\Miep\Sounds` or `C:\Users\Miep\Sounds\`.
2162 On Macintosh, `/Users/miep/Sounds` or `/Users/miep/Sounds/`. Any of these produce
2163 a list of all the files in the specified folder.
2164
2165 The other way is to specify a wildcard (a single asterisk) for the file names.
2166 To get a list of all the files whose names start with “`hal`” and end in “`.wav`”,
2167 use `/usr/people/miep/sounds/hal*.wav`, `C:\Users\Miep\Sounds\hal*.wav`,
2168 or `/Users/miep/Sounds/hal*.wav`.
2169
2170 You can even use %two wildcards: #`fileNames$#` (“/usr/people/miep/sounds/*al*.wav”)
2171 gives you a list of all files whose names contain “al” and end in “wav`.
2172
2173 Usage
2174 =====
2175 In a script, you can use this command to cycle through the files in a folder.
2176 For instance, to read in all the sound files in a specified folder,
2177 you could use the following script:
2178 {;
2179 folder$ = “/usr/people/miep/sounds”
2180 list$# = \#`{fileNames$#}: folder$ + “/*.wav”
2181 for ifile to \`{size} (list$#)
2182 \@{Read from file:} folder$ + “/” + list$# [ifile]
2183 endfor
2184 }
2185 If the script has been saved to a script file, you can use file paths that are relative to the folder
2186 where you saved the script. Thus, with
2187 {;
2188 list$# = \#`{fileNames$#}: “*.wav”
2189 }
2190 you get a list of all the `.wav` files that are in the same folder as the script that contains this line.
2191 And to get a list of all the `.wav` files in the folder `Sounds` that resides in the same folder as your script,
2192 you can do
2193 {;
2194 list$# = \#`{fileNames$#}: “Sounds/*.wav”
2195 }
2196 As is usual in Praat scripting, the forward slash (“/”) in this example can be used on all platforms, including Windows.
2197 This makes your script portable across platforms.
2198
2199 Note that the above functionality can also be written four lines shorter, using built-in functions:
2200 {;
2201 folder$ = “/usr/people/miep/sounds”
2202 list$# = \#`{fileNames$#}: folder$ + “/*.wav”
2203 for ifile to \`{size} (list$#)
2204 \@{Read from file:} folder$ + “/” + list$# [ifile]
2205 endfor
2206 }
2207
2208 See also
2209 ========
2210 - @`folderNames$#` for finding %folder names
2211 - @`fileNames_caseInsensitive$#` for %%case-insensitive% matching
2212
2213 ################################################################################
2214 "`fileNames_caseInsensitive$#`"
2215 © Paul Boersma 2023
2216
2217 A function that can be used in @@Formulas@, especially in @Scripting.
2218
2219 Syntax and semantics
2220 ====================
2221 #`fileNames_caseInsensitive$#` (%`folderNameOrPattern$`)
2222 : return the names (not the whole paths) of the files in a folder
2223 or that match a file-name pattern with up to two asterisks.
2224
2225 See also
2226 ========
2227 - @`folderNames_caseInsensitive$#` for finding %folder names
2228 - @`fileNames$#` for %%case-sensitive% matching
2229
2230 ################################################################################
2231 "`fileReadable`"
2232 © Paul Boersma 2023,2024
2233
2234 A function that can be used in @@Formulas@, especially in @Scripting.
2235
2236 Syntax and semantics
2237 ====================
2238 #`fileReadable` (%`filePath$`)
2239 : return 1 if the file exists and can be read, or 0 otherwise
2240 (e.g. if %`filePath$` does not exist or refers to a folder).
2241
2242 ################################################################################
2243 "`fisherP`"
2244 © Paul Boersma 2023
2245
2246 A function that can be used in @@Formulas@: the cumulative Fisher’s F-distribution.
2247
2248 Syntax and semantics
2249 ====================
2250 #`fisherP` (%`f`, %`df1`, %`df2`)
2251 : compute the area under Fisher’s F-distribution \-m\oo to %f,
2252 for %`df1` numerator degrees of freedom and %`df2` denominator degrees of freedom.
2253
2254 ################################################################################
2255 "`fisherQ`"
2256 © David Weenink 2000, Paul Boersma 2023
2257
2258 A function that can be used in @@Formulas@.
2259
2260 Syntax and semantics
2261 ====================
2262 #`fisherQ` (%`f`, %`df1`, %`df2`)
2263 : compute the area under Fisher’s F-distribution from %f to +\oo,
2264 for %`df1` numerator degrees of freedom and %`df2` denominator degrees of freedom.
2265
2266 Related functions
2267 =================
2268 (1) #`fisherQ` is the inverse of @`invFisherQ`, i.e.
2269 ~ fisherQ (invFisherQ (%q, %df_1, %df_2), %df_1, %df_2) = %q
2270
2271 , and
2272 ~ invFisherQ (fisherQ (%f, %df_1, %df_2), %df_1, %df_2) = %f
2273
2274 (2) #`fisherQ` is the complement of @`fisherP`, i.e.
2275 ~ fisherQ (%f, %df1, %df2) = 1 \-m fisherP (%f, %df1, %df2)
2276
2277 , and
2278 ~ fisherP (%f, %df1, %df2) = 1 \-m fisherQ (%f, %df1, %df2)
2279
2280 ################################################################################
2281 "`fixed$`"
2282 © Paul Boersma 2023,2025
2283
2284 A function that can be used in @@Formulas@.
2285
2286 Syntax and semantics
2287 ====================
2288 #`fixed$` (%`number`, %`precision`)
2289 : format a number as a string, with %`precision` digits after the decimal point.
2290
2291 #`fixed$` (%`vector#`, %`precision`)
2292 : format a vector as a string, with all elements expressed in %`precision` digits after the decimal point.
2293
2294 #`fixed$` (%`matrix##`, %`precision`)
2295 : format a matrix as a string, with all cells expressed in %`precision` digits after the decimal point.
2296
2297 Examples
2298 ========
2299
2300 {
2301 assert fixed$ (pi, 3) = "3.142"
2302 assert fixed$ (-1, 3) = "-1.000"
2303 assert fixed$ (1e6, 3) = "1000000.000"
2304 assert fixed$ (0.01, 3) = "0.010"
2305 assert fixed$ (0.001, 3) = "0.001"
2306 assert fixed$ (0.0001, 3) = "0.0001" ; never less than 1 significant digit!
2307
2308 assert fixed$ ({ pi, -1, 1e6, 0.0001 }, 3) =
2309 ... "3.142" + newline$ + "-1.000" + newline$ +
2310 ... "1000000.000" + newline$ + "0.0001" + newline$
2311 }
2312
2313 ################################################################################
2314 "`floor`"
2315 © Paul Boersma 2023
2316
2317 A function that can be used in @@Formulas@.
2318
2319 Syntax and semantics
2320 ====================
2321 #`floor` (%`x`)
2322 : round %`x` down to the nearest integer number.
2323
2324 ################################################################################
2325 "`floor#`"
2326 © Paul Boersma 2023
2327
2328 A function that can be used in @@Formulas@.
2329
2330 Syntax and semantics
2331 ====================
2332 #`floor#` (%`v#`)
2333 : round down (@`floor`) each element of the vector %`v#`.
2334
2335 ################################################################################
2336 "`floor##`"
2337 © Paul Boersma 2023
2338
2339 A function that can be used in @@Formulas@.
2340
2341 Syntax and semantics
2342 ====================
2343 #`floor##` (%`m##`)
2344 : round down (@`floor`) each cell of the matrix %`m##`.
2345
2346 ################################################################################
2347 "`folderExists`"
2348 © Paul Boersma 2024
2349
2350 A function that can be used in @@Formulas@, especially in @Scripting.
2351
2352 Syntax and semantics
2353 ====================
2354 #`folderExists` (%`folderPath$`)
2355 : return 1 if the folder exists, or 0 otherwise
2356 (e.g. if %`folderPath$` does not exist or refers to a file).
2357
2358 ################################################################################
2359 "`folderNames$#`"
2360 © Paul Boersma 2023
2361
2362 A function that can be used in @@Formulas@, especially in @Scripting.
2363
2364 Syntax and semantics
2365 ====================
2366 #`folderNames$#` (%`folderNameOrPattern$`)
2367 : return the names (not the whole paths) of the subfolders in a folder
2368 or that match a subfolder-name pattern with up to two asterisks.
2369
2370 See also
2371 ========
2372 - @`fileNames$#` for finding %file names
2373 - @`folderNames_caseInsensitive$#` for %%case-insensitive% matching
2374
2375 ################################################################################
2376 "`folderNames_caseInsensitive$#`"
2377 © Paul Boersma 2023
2378
2379 A function that can be used in @@Formulas@, especially in @Scripting.
2380
2381 Syntax and semantics
2382 ====================
2383 #`folderNames_caseInsensitive$#` (%`folderNameOrPattern$`)
2384 : return the names (not the whole paths) of the subfolders in a folder
2385 or that match a subfolder-name pattern with up to two asterisks.
2386
2387 See also
2388 ========
2389 - @`fileNames_caseInsensitive$#` for finding %file names
2390 - @`folderNames$#` for %%case-sensitive% matching
2391
2392 ################################################################################
2393 "`from_to#`"
2394 © Paul Boersma 2023
2395
2396 A function that can be used in @@Formulas@.
2397
2398 Syntax and semantics
2399 ====================
2400 #`from_to#` (%`m`, %`n`)
2401 : return the integers from %`m` through %`n`.
2402
2403 ################################################################################
2404 "`from_to_by#`"
2405 © Paul Boersma 2023
2406
2407 A function that can be used in @@Formulas@.
2408
2409 Syntax and semantics
2410 ====================
2411 #`from_to_by#` (%`m`, %`n`, %`step`)
2412 : return the numbers from %`m` through %`n`, in steps of %`step`.
2413
2414 ################################################################################
2415 "`from_to_count#`"
2416 © Paul Boersma 2023-06-30
2417
2418 A function that can be used in @@Formulas@.
2419
2420 Syntax and semantics
2421 ====================
2422 #`from_to_count#` (%`start`, %`end`, %`n`)
2423 : return %`n` equally-spaced numbers
2424 starting with %`start` and ending with %`end`.
2425
2426 ################################################################################
2427 "`gaussP`"
2428 © Paul Boersma 2023
2429
2430 A function that can be used in @@Formulas@: the cumulative normal (Gauss) distribution.
2431
2432 Syntax and semantics
2433 ====================
2434 #``gaussP` (%`z`)
2435 : compute the area under the normal distribution
2436 (with mean 0 and standard deviation 1) from \-m\oo to %`z`.
2437
2438 ################################################################################
2439 "`gaussQ`"
2440 © Paul Boersma 2023
2441
2442 A function that can be used in @@Formulas@.
2443
2444 Syntax and semantics
2445 ====================
2446 #`gaussQ` (%`z`)
2447 : compute the area under the normal distribution
2448 (with mean 0 and standard deviation 1) from %z to +\oo.
2449
2450 Related functions
2451 =================
2452 (1) #`gaussQ` is the inverse of @`invGaussQ`, i.e.
2453 ~ gaussQ (invGaussQ (%q)=) = %q
2454
2455 , and
2456 ~ invGaussQ (gaussQ (%z)) = %z
2457
2458 (2) #`gaussQ` is the complement of @`gaussP`, i.e.
2459 ~ gaussQ (%z) = 1 \-m gaussP (%z)
2460
2461 , and
2462 ~ gaussP (%z) = 1 \-m gaussQ (%z)
2463
2464 ################################################################################
2465 "`goto`"
2466 © Paul Boersma 2023
2467
2468 A keyword that can be used in @Scripting, for control flow.
2469
2470 Syntax and semantics
2471 ====================
2472 #`goto` %`LABEL`
2473 : jump from here to the line that contains `label \%{LABEL}`,
2474 where %`LABEL` can be any sequence of letters (usually upper case), underscores and digits.
2475
2476 See also @`label`.
2477
2478 ################################################################################
2479 "`hertzToBark`"
2480 © Paul Boersma 2023
2481
2482 A function that can be used in @@Formulas@.
2483
2484 Syntax and semantics
2485 ====================
2486 #`hertzToBark` (%`x`)
2487 : convert from an acoustic frequency %x in Hz to an auditory Bark-rate
2488 (auditory spectral frequency; place on basilar membrane).
2489
2490 Definition
2491 ==========
2492 ~ #`hertzToBark` (%x) = 7 ln (%x/650 + \Vr(1 + (%x/650)^2))
2493
2494 ################################################################################
2495 "`hertzToErb`"
2496 © Paul Boersma 2023
2497
2498 A function that can be used in @@Formulas@.
2499
2500 Syntax and semantics
2501 ====================
2502 #`hertzToErb` (%`x`)
2503 : convert from an acoustic frequency %`x` in Hz to an auditory ERB-rate.
2504
2505 Definition
2506 ==========
2507 ~ #`hertzToErb` (%x) = 11.17 ln ((%x + 312) / (%x + 14680)) + 43
2508
2509 ################################################################################
2510 "`hertzToMel`"
2511 © Paul Boersma 2023
2512
2513 A function that can be used in @@Formulas@.
2514
2515 Syntax and semantics
2516 ====================
2517 #`hertzToMel` (%`x`)
2518 : convert from an acoustic frequency %`x` in Hz to an auditory pitch in mel.
2519
2520 Definition
2521 ==========
2522 ~ #`hertzToMel` (%x) 550 ln (1 + %x / 550).
2523
2524 ################################################################################
2525 "`hertzToSemitones`"
2526 © Paul Boersma 2023
2527
2528 A function that can be used in @@Formulas@.
2529
2530 Syntax and semantics
2531 ====================
2532 #`hertzToSemitones` (%`x`)
2533 : convert from an acoustic frequency %x in Hz
2534 to a logarithmic musical scale relative to 100 Hz.
2535
2536 Definition
2537 ==========
2538 ~ #`hertzToSemitones` (%x) = 12 ln (%x / 100) / ln 2
2539
2540 ################################################################################
2541 "`imax`"
2542 © Paul Boersma 2023
2543
2544 A function that can be used in @@Formulas@.
2545
2546 Syntax and semantics
2547 ====================
2548 #`imax` (%`x`, `...`)
2549 : determine the location of the maximum of a sequence of numbers.
2550
2551 Tests
2552 =====
2553 {
2554 assert imax (7.2, -5, 3) = 1
2555 }
2556
2557 ################################################################################
2558 "`imin`"
2559 © Paul Boersma 2023
2560
2561 A function that can be used in @@Formulas@.
2562
2563 Syntax and semantics
2564 ====================
2565 #`imin` (%`x`, `...`)
2566 : determine the location of the minimum of a sequence of numbers.
2567
2568 Tests
2569 =====
2570 {
2571 assert imin (7.2, -5, 3) = 2
2572 }
2573
2574 ################################################################################
2575 "`index`"
2576 © Paul Boersma 2023
2577
2578 A function that can be used in @@Formulas@.
2579
2580 Syntax and semantics
2581 ====================
2582 #`index` (%`string$`, %`part$`)
2583 : return the first location of the substring %`part$` inside %`string$`, or 0 if not found.
2584
2585 #`index` (%`strings$#`, %`s$`)
2586 : look up whether and where %`s$` first occurs in %`strings$#`.
2587
2588 See also
2589 ========
2590 - @`rindex` for the %last occurrence
2591 - @`index_caseInsensitive` for %%case-insensitive% matching
2592 - @`index_regex` for %%regular-expression% matching
2593
2594 ################################################################################
2595 "`index_caseInsensitive`"
2596 © Paul Boersma 2023
2597
2598 A function that can be used in @@Formulas@.
2599
2600 Syntax and semantics
2601 ====================
2602 #`index_caseInsensitive` (%`string$`, %`part$`)
2603 : return the first location of the substring %`part$` inside %`string$`, or 0 if not found.
2604
2605 #`index_caseInsensitive` (%`strings$#`, %`s$`)
2606 : look up whether and where %`s$` first occurs in %`strings$#`.
2607
2608 Case insensitivity
2609 ==================
2610 For determining where the substring is located,
2611 it doesn’t matter whether %`string$` and/or %`part$` are in lower case or upper case.
2612 Here is a comparison with @`index`:
2613 {
2614 assert \`{index} ("hello", "L") = 0
2615 assert \#{index_caseInsensitive} ("hello", "L") = 3
2616 assert \`{index} ("heLlo", "L") = 3
2617 assert \#{index_caseInsensitive} ("heLlo", "L") = 3
2618 assert \`{index} ("helLo", "L") = 4
2619 assert \#{index_caseInsensitive} ("helLo", "L") = 3
2620 assert \`{index} ("heLLo", "L") = 3
2621 assert \#{index_caseInsensitive} ("heLLo", "L") = 3
2622 }
2623 See also
2624 ========
2625 - @`rindex_caseInsensitive` for the %last occurrence
2626 - @`index` for %%case-sensitive% matching
2627
2628 ################################################################################
2629 "`index_regex`"
2630 © Paul Boersma 2023
2631
2632 A function that can be used in @@Formulas@.
2633
2634 Syntax and semantics
2635 ====================
2636 #`index_regex` (%`string$`, %`regex$`)
2637 : determine whether and where %`string$` first matches %`regex$`.
2638 See @@Regular expressions@.
2639
2640 ################################################################################
2641 "`inner`"
2642 © Paul Boersma 2023
2643
2644 A function that can be used in @@Formulas@.
2645
2646 Syntax and semantics
2647 ====================
2648 #`inner` (%`a#`, %`b#`)
2649 : compute the inner product of the vectors %`a#` and %`b#`.
2650
2651 ################################################################################
2652 "`invBinomialP`"
2653 © Paul Boersma 2023
2654
2655 A function that can be used in @@Formulas@.
2656
2657 Syntax and semantics
2658 ====================
2659 #`invBinomialP` (%`p`, %`k`, %`n`)
2660 : return the inverse cumulative binomial distribution,
2661 i.e. the value %prob for which @`binomialP` (%`prob`, %`k`, %`n`) = %`p`.
2662
2663 ################################################################################
2664 "`invBinomialQ`"
2665 © Paul Boersma 2023
2666
2667 A function that can be used in @@Formulas@.
2668
2669 Syntax and semantics
2670 ====================
2671 #`invBinomialQ` (%`q`, %`k`, %`n`)
2672 : return the inverse cumulative binomial distribution,
2673 i.e. the value %prob for which @`binomialQ` (%`prob`, %`k`, %`n`) = %`q`.
2674
2675 ################################################################################
2676 "`invChiSquareQ`"
2677 © Paul Boersma 2023
2678
2679 A function that can be used in @@Formulas@.
2680
2681 Syntax and semantics
2682 ====================
2683 #`invChiSquareQ` (%`q`, %`df`)
2684 : return the inverse %\ci^2 (chi-square) distribution,
2685 i.e. the value %chisq for which @`chiSquareQ` (%`chisq`, %`df`) = %`q`.
2686
2687 ################################################################################
2688 "`invFisherQ`"
2689 © David Weenink 2000, Paul Boersma 2023
2690
2691 A function that can be used in @@Formulas@.
2692
2693 Syntax and semantics
2694 ====================
2695 #`invFisherQ` (%`q`, %`df1`, %`df2`)
2696 : return the inverse cumulative Fisher F-distribution,
2697 i.e. the value %f for which @`fisherQ` (%`f`, %`df1`, %`df2`) = %`q`.
2698
2699 ################################################################################
2700 "`invGaussQ`"
2701 © Paul Boersma 2023
2702
2703 A function that can be used in @@Formulas@.
2704
2705 Syntax and semantics
2706 ====================
2707 #`invGaussQ` (%`q`)
2708 : return the inverse cumulative normal (Gauss) distribution,
2709 i.e. the value %z for which @`gaussQ` (%`z`) = %`q`.
2710
2711 ################################################################################
2712 "`invSigmoid`"
2713 © Paul Boersma 2023
2714
2715 A function that can be used in @@Formulas@.
2716
2717 Syntax and semantics
2718 ====================
2719 #`invSigmoid` (%`x`)
2720 : compute the inverse @`sigmoid`.
2721
2722 Definition
2723 ==========
2724 ~ #`invSigmoid` (%x) = ln (%x / (1 − %x)).
2725
2726 Domain and range
2727 ================
2728 #`invSigmoid` (%x) is defined for 0 < %`x` < 1.
2729 The possible results are all real numbers.
2730
2731 ################################################################################
2732 "`invSigmoid#`"
2733 © Paul Boersma 2023
2734
2735 A function that can be used in @@Formulas@.
2736
2737 Syntax and semantics
2738 ====================
2739 #`invSigmoid#` (%`v#`)
2740 : compute the inverse sigmoid (@`invSigmoid`) of each element of the vector %`v#`.
2741
2742 ################################################################################
2743 "`invSigmoid##`"
2744 © Paul Boersma 2023
2745
2746 A function that can be used in @@Formulas@.
2747
2748 Syntax and semantics
2749 ====================
2750 #`invSigmoid##` (%`m##`)
2751 : compute the inverse sigmoid (@`invSigmoid`) of each cell of the matrix %`m##`.
2752
2753 ################################################################################
2754 "`invStudentQ`"
2755 © Paul Boersma 2023
2756
2757 A function that can be used in @@Formulas@.
2758
2759 Syntax and semantics
2760 ====================
2761 #`invStudentQ` (%`q`, %`df`)
2762 : return the inverse cumulative Student %t distribution,
2763 i.e. the value %t for which @`studentQ` (%`t`, %`df`) = %`q`.
2764
2765 ################################################################################
2766 "`label`"
2767 © Paul Boersma 2023
2768
2769 A keyword that can be used in @Scripting, for control flow.
2770
2771 Syntax and semantics
2772 ====================
2773 #`label` %`LABEL`
2774 : proceed from here, perhaps after jumping from a line that contains `goto \%{LABEL}`,
2775 where %`LABEL` can be any sequence of letters (usually upper case), underscores and digits.
2776
2777 See also @`goto`.
2778
2779 ################################################################################
2780 "`left$`"
2781 © Paul Boersma 2023
2782
2783 A function that can be used in @@Formulas@.
2784
2785 Syntax and semantics
2786 ====================
2787 #`left$` (%`string$`, %`n`)
2788 : return the %`n` first characters in %`string$`.
2789
2790 ################################################################################
2791 "`length`"
2792 © Paul Boersma 2023
2793
2794 A function that can be used in @@Formulas@.
2795
2796 Syntax and semantics
2797 ====================
2798 #`length` (%`string$`)
2799 : return the number of Unicode characters in %`string$`.
2800
2801 ################################################################################
2802 "`ln`"
2803 © Paul Boersma 2023
2804
2805 A function that can be used in @@Formulas@.
2806
2807 Syntax and semantics
2808 ====================
2809 #`ln` (%`x`)
2810 : return the natural logarithm of %`x`, i.e. the logarithm with base %e.
2811
2812 ################################################################################
2813 "`ln#`"
2814 © Paul Boersma 2023
2815
2816 A function that can be used in @@Formulas@.
2817
2818 Syntax and semantics
2819 ====================
2820 #`ln#` (%`v#`)
2821 : compute the natural logarithm (@`ln`) of each element of the vector %`v#`.
2822
2823 ################################################################################
2824 "`ln##`"
2825 © Paul Boersma 2023
2826
2827 A function that can be used in @@Formulas@.
2828
2829 Syntax and semantics
2830 ====================
2831 #`ln##` (%`m##`)
2832 : compute the natural logarithm (@`ln`) of each cell of the matrix %`m##`.
2833
2834 ################################################################################
2835 "`lnGamma`"
2836 © Paul Boersma 2023
2837
2838 A function that can be used in @@Formulas@.
2839
2840 Syntax and semantics
2841 ====================
2842 #`lnGamma` (%`x`)
2843 : return the natural logarithm of the \Ga function of %`x`.
2844
2845 ################################################################################
2846 "`log2`"
2847 © Paul Boersma 2023
2848
2849 A function that can be used in @@Formulas@.
2850
2851 Syntax and semantics
2852 ====================
2853 #`log2` (%`x`)
2854 : return the base-2 logarithm of %`x`.
2855
2856 ################################################################################
2857 "`log2#`"
2858 © Paul Boersma 2023
2859
2860 A function that can be used in @@Formulas@.
2861
2862 Syntax and semantics
2863 ====================
2864 #`log2#` (%`v#`)
2865 : compute the base-2 logarithm (@`log2`) of each element of the vector %`v#`.
2866
2867 ################################################################################
2868 "`log2##`"
2869 © Paul Boersma 2023
2870
2871 A function that can be used in @@Formulas@.
2872
2873 Syntax and semantics
2874 ====================
2875 #`log2##` (%`m##`)
2876 : compute the base-2 logarithm (@`log2`) of each cell of the matrix %`m##`.
2877
2878 ################################################################################
2879 "`log10`"
2880 © Paul Boersma 2023
2881
2882 A function that can be used in @@Formulas@.
2883
2884 Syntax and semantics
2885 ====================
2886 #`log10` (%`x`)
2887 : return the base-10 logarithm of %`x`.
2888
2889 ################################################################################
2890 "`log10#`"
2891 © Paul Boersma 2023
2892
2893 A function that can be used in @@Formulas@.
2894
2895 Syntax and semantics
2896 ====================
2897 #`log10#` (%`v#`)
2898 : compute the base-10 logarithm (@`log10`) of each element of the vector %`v#`.
2899
2900 ################################################################################
2901 "`log10##`"
2902 © Paul Boersma 2023
2903
2904 A function that can be used in @@Formulas@.
2905
2906 Syntax and semantics
2907 ====================
2908 #`log10##` (%`m##`)
2909 : compute the base-10 logarithm (@`log10`) of each cell of the matrix %`m##`.
2910
2911 ################################################################################
2912 "`lowerCase$`"
2913 © Paul Boersma 2025
2914
2915 A function that can be used in @@Formulas@. It turns all capitals
2916 into lower-case characters.
2917
2918 Syntax and semantics
2919 ====================
2920 #`lowerCase$` (%`string$`)
2921 : give the lower-case version of %`string$`, whereby all upper-case letters
2922 have been replaced with lower-case letters.
2923
2924 Tests
2925 =====
2926 {
2927 \`{assert} \#{lowerCase$} ("HOwAREYou") = "howareyou"
2928 \`{assert} \#{lowerCase$} ("Maria Ressa") = "maria ressa"
2929 \`{assert} \#{lowerCase$} ("GSL") = "gsl"
2930 \`{assert} \#{lowerCase$} ("ÖAV") = "öav"
2931 \`{assert} \#{lowerCase$} ("TOUCHÉ") = "touché"
2932 }
2933
2934 ################################################################################
2935 "`lowerCaseAppName$`"
2936 © Paul Boersma 2024
2937
2938 A function that can be used in @@Formulas@. The name of the present app,
2939 in lower snake case, such as `praat` or `praat_for_hospitals`.
2940
2941 Syntax and semantics
2942 ====================
2943 #`lowerCaseAppName$` ( )
2944 : give the name of the present app, in lower snake case.
2945
2946 Examples
2947 ========
2948 {
2949 writeInfoLine: \#{lowerCaseAppName$} ( )
2950 }
2951
2952 ################################################################################
2953 "`max`"
2954 © Paul Boersma 2023
2955
2956 A function that can be used in @@Formulas@.
2957
2958 Syntax and semantics
2959 ====================
2960 #`max` (%`x`, `...`)
2961 : determine the maximum of a list of numbers.
2962
2963 Tests
2964 =====
2965 {
2966 \`{assert} \#{max} (7.2, -5, 3) = 7.2
2967 }
2968
2969 ################################################################################
2970 "`mean`"
2971 © Paul Boersma 2023
2972
2973 A function that can be used in @@Formulas@.
2974
2975 Syntax and semantics
2976 ====================
2977 #`mean` (%`v#`)
2978 : compute the average of the elements of the vector `v#`.
2979
2980 ################################################################################
2981 "`melToHertz`"
2982 © Paul Boersma 2023-06-30
2983
2984 A function that can be used in @Formulas.
2985
2986 Syntax and semantics
2987 ====================
2988 #`melToHertz` (%`x`)
2989 : convert from an auditory pitch %`x` in mel to an acoustic frequency in Hz.
2990
2991 Definition
2992 ==========
2993 ~ #`melToHertz` (%x) 550 (exp (%x / 550) - 1).
2994
2995 ################################################################################
2996 "`mid$`"
2997 © Paul Boersma 2023
2998
2999 A function that can be used in @@Formulas@.
3000
3001 Synopsis
3002 ========
3003 #`mid$` (%`string$`, %`from`, %`n`)
3004 : return the %`n` characters in %`string$` starting at position %`from`.
3005
3006 ################################################################################
3007 "`min`"
3008 © Paul Boersma 2023
3009
3010 A function that can be used in @@Formulas@.
3011
3012 Syntax and semantics
3013 ====================
3014 #`min` (%`x`, `...`)
3015 : determine the minimum of a list of numbers.
3016
3017 Tests
3018 =====
3019 {
3020 assert min (7.2, -5, 3) = -5
3021 }
3022
3023 ################################################################################
3024 "`minusObject`"
3025 © Paul Boersma 2023
3026
3027 A function that can be used in @@Formulas@.
3028
3029 Syntax and semantics
3030 ====================
3031 #`minusObject` (`...`)
3032 : deselect the objects given by IDs and/or full names.
3033
3034 ################################################################################
3035 "`moveAndOrRenameFile`"
3036 © Paul Boersma 2025
3037
3038 A function that can be used in @Scripting.
3039
3040 Syntax and semantics
3041 ====================
3042 #`moveAndOrRenameFile` (%`fromFilePath$`, %`toFilePath$`)
3043 : move and/or rename an existing file to a new location and/or name.
3044
3045 Example: rename
3046 ===============
3047 {;
3048 \#{moveAndOrRenameFile} (“/Users/me/Desktop/hello.wav”,
3049 ... “/Users/me/Desktop/goodbye.wav”)
3050 }
3051
3052 Example: move
3053 ===============
3054 {;
3055 \#{moveAndOrRenameFile} (“/Users/me/Desktop/hello.wav”,
3056 ... “/Users/me/sound files/hello.wav”)
3057 }
3058
3059 Example: move and rename
3060 ========================
3061 {;
3062 \#{moveAndOrRenameFile} (“/Users/me/Desktop/hello.wav”,
3063 ... “/Users/me/sound files/goodbye.wav”)
3064 }
3065
3066 ################################################################################
3067 "`mul##`"
3068 © Paul Boersma 2023
3069
3070 A function that can be used in @@Formulas@.
3071
3072 Syntax and semantics
3073 ====================
3074 #`mul##` (%`a##`, %`b##`)
3075 : perform a matrix multiplication of the matrices %`a##` and %`b##`.
3076
3077 ################################################################################
3078 "`ncol`"
3079 © Paul Boersma 2024
3080
3081 The number of columns of an object.
3082
3083 See @@Formulas 8. Attributes of objects@.
3084
3085 ################################################################################
3086 "`nrow`"
3087 © Paul Boersma 2024
3088
3089 The number of rows of an object.
3090
3091 See @@Formulas 8. Attributes of objects@.
3092
3093 ################################################################################
3094 "`number`"
3095 © Paul Boersma 2023,2024
3096
3097 A function that can be used in @@Formulas@.
3098
3099 Syntax and semantics
3100 ====================
3101 #`number` (%`a$`)
3102 : interpret a string as a number.
3103
3104 {
3105 \`{assert} \#{number} ("0.0") = 0
3106 \`{assert} \#{number} ("0.00123") = 0.00123 ; decimal point
3107 \`{assert} \#{number} ("12e34") = 1.2e+35 ; exponent introduced by "e" or "E"
3108 \`{assert} \#{number} ("junk") = undefined ; i.e. not zero as in C++ !
3109 \`{assert} \#{number} (" -0.0000000123junk") = -1.23e-08 ; maximize digits, then ignore
3110 \`{assert} \#{number} ("1.0e+309") = undefined
3111 \`{assert} \#{number} ("1.0e-309") <> 0 ; denormalized
3112 \`{assert} \#{number} ("1.0e-319") <> 0 ; denormalized
3113 \`{assert} \#{number} ("1.0e-329") = 0 ; underflow
3114 \`{assert} \#{number} ("32278") = 32278
3115 \`{assert} \#{number} ("-32278") = -32278
3116 \`{assert} \#{number} ("32278.64785") = 32278.64785
3117 \`{assert} \#{number} ("-32278.64785") = -32278.64785
3118 \`{assert} \#{number} ("32278.647e85") = 32278.647e85
3119 \`{assert} \#{number} ("-32278.647e85") = -32278.647e85
3120 \`{assert} \#{number} ("32278.647e-85") = 32278.647e-85
3121 \`{assert} \#{number} ("-32278.647e-85") = -32278.647e-85
3122 \`{assert} \#{number} ("32278.647e-305") = 32278.647e-305
3123 \`{assert} \#{number} ("-32278.647e-305") = -32278.647e-305
3124 \`{assert} \#{number} ("32278.647e-315") = 32278.647e-315
3125 \`{assert} \#{number} ("-32278.647e-315") = -32278.647e-315
3126 \`{assert} \#{number} ("32278.647e-325") = 32278.647e-325
3127 \`{assert} \#{number} ("-32278.647e-325") = -32278.647e-325
3128 \`{assert} \#{number} ("32278.647e305") = 32278.647e305
3129 \`{assert} \#{number} ("-32278.647e305") = -32278.647e305
3130 \`{assert} \#{number} ("32278.647e315") = 32278.647e315
3131 \`{assert} \#{number} ("-32278.647e315") = -32278.647e315
3132 \`{assert} \#{number} ("32278.647e325") = 32278.647e325
3133 \`{assert} \#{number} ("-32278.647e325") = -32278.647e325
3134 }
3135 Hexadecimal:
3136 {
3137 \`{assert} \#{number} ("0x32278") = 0x32278
3138 \`{assert} \#{number} ("0x123") = 291
3139 \`{assert} \#{number} ("0x000001ABCDEFGH") = 0x00001abcdef ; maximize digits, then ignore
3140 \`{assert} \#{number} ("0x123.456") = 291.27099609375
3141 \`{assert} \#{number} ("0x123.abc") = 291.6708984375 ; hexadecimal point
3142 \`{assert} \#{number} ("0x123.abcp-1") = 145.83544921875 ; exponent introduced by "p" or "P"
3143 \`{assert} \#{number} ("0x123.abcP-2") = 72.917724609375
3144 \`{assert} \#{number} ("0x123.abcp-12") = 0.07120871543884277 ; the exponent is decimal !
3145 \`{assert} \#{number} ("0x123.abcp-1A2") = 145.83544921875 ; the exponent is decimal !
3146 \`{assert} \#{number} ("-0x1afp-2") = -107.75 ; from `cppreference.com`
3147 }
3148
3149 ################################################################################
3150 "`number#`"
3151 © Paul Boersma 2023
3152
3153 A function that can be used in @@Formulas@.
3154
3155 Syntax and semantics
3156 ====================
3157 #`number#` (%`a$#`)
3158 : interpret strings as numbers.
3159
3160 ################################################################################
3161 "`numberOfColumns`"
3162 © Paul Boersma 2023
3163
3164 A function that can be used in @@Formulas@.
3165
3166 Syntax and semantics
3167 ====================
3168 #`numberOfColumns` (%`m##`)
3169 : return the number of columns of the matrix %`m##`.
3170
3171 ################################################################################
3172 "`numberOfRows`"
3173 © Paul Boersma 2023
3174
3175 A function that can be used in @@Formulas@.
3176
3177 Syntax and semantics
3178 ====================
3179 #`numberOfRows` (%`m##`)
3180 : return the number of rows of the matrix %`m##`.
3181
3182 ################################################################################
3183 "`nx`"
3184 © Paul Boersma 2024
3185
3186 The number of cells horizontally (i.e. the number of columns) of an object.
3187 This is the same as @`ncol`.
3188
3189 See @@Formulas 8. Attributes of objects@.
3190
3191 ################################################################################
3192 "`ny`"
3193 © Paul Boersma 2024
3194
3195 The number of cells vertically (i.e. the number of rows) of an object.
3196 This is the same as @`nrow`.
3197
3198 See @@Formulas 8. Attributes of objects@.
3199
3200 ################################################################################
3201 "`outer##`"
3202 © Paul Boersma 2023
3203
3204 A function that can be used in @@Formulas@.
3205
3206 Syntax and semantics
3207 ====================
3208 #`outer##` (%`a#`, %`b#`)
3209 : compute the outer product of the vectors %`a#` and %`b#`.
3210
3211 Definition
3212 ==========
3213 ~ %result__%i%j_ = %a_%i %b_%j
3214
3215 ################################################################################
3216 "`padLeft$`"
3217 © Paul Boersma 2024
3218
3219 A function that can be used in @@Formulas@.
3220
3221 Syntax and semantics
3222 ====================
3223 #`padLeft$` (%`string$`, %`minimumNewWidth` [, %`pad$`])
3224 : add characters (selected from %`pad$`) to the left of %`string$` until the result is at least as long as %`minimumNewWidth`:
3225 {
3226 \`{assert} \#{padLeft$} ("hello", 12, ".") = ".......hello"
3227 \`{assert} \#{padLeft$} ("hello", 5, ".") = "hello"
3228 }
3229 If %`pad$` is not given, the padding will be done with spaces:
3230 {
3231 \`{assert} \#{padLeft$} ("hello", 12) = " hello"
3232 }
3233 No truncation takes place, so the resulting string may be longer than %`minimumNewWidth`:
3234 {
3235 \`{assert} \#{padLeft$} ("hello", 3) = "hello"
3236 \`{assert} \#{padLeft$} ("hello", -100) = "hello"
3237 }
3238 If %`pad$` contains more than one character, the left edge of %`pad$` is left-aligned to the resulting string,
3239 so that the result will look good if padding is used for visualizing columns:
3240 {
3241 \`{assert} \#{padLeft$} ("hello", 12, ".-;)") = ".-;).-;hello"
3242 \`{assert} \#{padLeft$} ("goodbye", 12, ".-;)") = ".-;).goodbye"
3243 }
3244 There will be an error message if padding is required but no characters are to be found in %`pad$`:
3245 {
3246 \`{asserterror} Empty pad string.
3247 a$ = \#{padLeft$} ("hello", 12, "")
3248 }
3249
3250 ################################################################################
3251 "`padOrTruncateLeft$`"
3252 © Paul Boersma 2024
3253
3254 A function that can be used in @@Formulas@.
3255
3256 Syntax and semantics
3257 ====================
3258 #`padOrTruncateLeft$` (%`string$`, %`newWidth` [, %`pad$`])
3259 : add characters (selected from %`pad$`) to the left of %`string$`, or remove characters from the left of %`string$`,
3260 until the result is precisely %`newWidth` characters long:
3261 {
3262 \`{assert} \#{padOrTruncateLeft$} ("hello", 12, ".") = ".......hello"
3263 \`{assert} \#{padOrTruncateLeft$} ("hello", 3, ".") = "llo"
3264 \`{assert} \#{padOrTruncateLeft$} ("hello", 0) = ""
3265 }
3266 If %`pad$` is not given, the padding will be done with spaces:
3267 {
3268 \`{assert} \#{padOrTruncateLeft$} ("hello", 12) = " hello"
3269 \`{assert} \#{padOrTruncateLeft$} ("hello", 3) = "llo"
3270 }
3271 If characters have to be added, and %`pad$` contains more than one character,
3272 the left edge of %`pad$` is left-aligned to the resulting string,
3273 so that the result will look good if padding is used for visualizing columns:
3274 {
3275 \`{assert} \#{padOrTruncateLeft$} ("hello", 12, ".-;)") = ".-;).-;hello"
3276 \`{assert} \#{padOrTruncateLeft$} ("goodbye", 12, ".-;)") = ".-;).goodbye"
3277 }
3278 Note that %`newWidth` cannot be negative:
3279 {
3280 \`{asserterror} Can never truncate a string down to -3 characters.
3281 a$ = \#{padOrTruncateLeft$} ("hello", -3)
3282 }
3283 There will be an error message if padding is required but no characters are to be found in %`pad$`:
3284 {
3285 \`{asserterror} Empty pad string.
3286 a$ = \#{padOrTruncateLeft$} ("hello", 12, "")
3287 }
3288
3289 ################################################################################
3290 "`padOrTruncateRight$`"
3291 © Paul Boersma 2024
3292
3293 A function that can be used in @@Formulas@.
3294
3295 Syntax and semantics
3296 ====================
3297 #`padOrTruncateRight$` (%`string$`, %`newWidth` [, %`pad$`])
3298 : add characters (selected from %`pad$`) to the right of %`string$`, or remove characters from the right of %`string$`,
3299 until the result is precisely %`newWidth` characters long:
3300 {
3301 \`{assert} \#{padOrTruncateRight$} ("hello", 12, ".") = "hello......."
3302 \`{assert} \#{padOrTruncateRight$} ("hello", 3, ".") = "hel"
3303 \`{assert} \#{padOrTruncateRight$} ("hello", 0) = ""
3304 }
3305 If %`pad$` is not given, the padding will be done with spaces:
3306 {
3307 \`{assert} \#{padOrTruncateRight$} ("hello", 12) = "hello "
3308 \`{assert} \#{padOrTruncateRight$} ("hello", 3) = "hel"
3309 }
3310 If characters have to be added, and %`pad$` contains more than one character,
3311 the right edge of %`pad$` is right-aligned to the resulting string,
3312 so that the result will look good if padding is used for visualizing columns:
3313 {
3314 \`{assert} \#{padOrTruncateRight$} ("hello", 12, ".-;)") = "hello-;).-;)"
3315 \`{assert} \#{padOrTruncateRight$} ("goodbye", 12, ".-;)") = "goodbye).-;)"
3316 }
3317 Note that %`newWidth` cannot be negative:
3318 {
3319 \`{asserterror} Can never truncate a string down to -3 characters.
3320 a$ = \#{padOrTruncateRight$} ("hello", -3)
3321 }
3322 There will be an error message if padding is required but no characters are to be found in %`pad$`:
3323 {
3324 \`{asserterror} Empty pad string.
3325 a$ = \#{padOrTruncateRight$} ("hello", 12, "")
3326 }
3327
3328 ################################################################################
3329 "`padRight$`"
3330 © Paul Boersma 2024
3331
3332 A function that can be used in @@Formulas@.
3333
3334 Syntax and semantics
3335 ====================
3336 #`padRight$` (%`string$`, %`minimumNewWidth` [, %`pad$`])
3337 : add characters (selected from %`pad$`) to the right of %`string$` until the result is at least as long as %`minimumNewWidth`:
3338 {
3339 \`{assert} \#{padRight$} ("hello", 12, ".") = "hello......."
3340 \`{assert} \#{padRight$} ("hello", 5, ".") = "hello"
3341 }
3342 If %`pad$` is not given, the padding will be done with spaces:
3343 {
3344 \`{assert} \#{padRight$} ("hello", 12) = "hello "
3345 }
3346 No truncation takes place, so the resulting string may be longer than %`minimumNewWidth`:
3347 {
3348 \`{assert} \#{padRight$} ("hello", 3) = "hello"
3349 \`{assert} \#{padRight$} ("hello", -100) = "hello"
3350 }
3351 If %`pad$` contains more than one character, the right edge of %`pad$` is right-aligned to the resulting string,
3352 so that the result will look good if padding is used for visualizing columns:
3353 {
3354 \`{assert} \#{padRight$} ("hello", 12, ".-;)") = "hello-;).-;)"
3355 \`{assert} \#{padRight$} ("goodbye", 12, ".-;)") = "goodbye).-;)"
3356 }
3357 There will be an error message if padding is required but no characters are to be found in %`pad$`:
3358 {
3359 \`{asserterror} Empty pad string.
3360 a$ = \#{padRight$} ("hello", 12, "")
3361 }
3362
3363 ################################################################################
3364 "`part#`"
3365 © Paul Boersma 2023
3366
3367 A function that can be used in @Formulas.
3368
3369 Syntax and semantics
3370 ====================
3371 #`part#` (%`vector#`, %`from`, %`to`)
3372 : compute a subsequence of elements of a vector.
3373
3374 Examples
3375 ========
3376 {
3377 \`{assert} part# ({ 7, 4, 99, 103, 1 }, 3, 4) = { 99, 103 }
3378 }
3379
3380 Examples of error messages
3381 ==========================
3382 Checks on the number of arguments (always has to be 3):
3383 {
3384 asserterror The function “part#” requires exactly three arguments
3385 ... (namely a vector, a starting index, and an end index),
3386 ... not the 0 given.
3387 a# = part# ()
3388
3389 asserterror The function “part#” requires exactly three arguments
3390 ... (namely a vector, a starting index, and an end index),
3391 ... not the 5 given.
3392 a# = part# (7, 8, 9, "hello", "world")
3393 }
3394 Checks on the types of the arguments (always has to be vector, number, number):
3395 {
3396 asserterror The first argument of the function “part#” should be
3397 ... a numeric vector, not a number.
3398 a# = part# (2, 4, { 5, 6, 7, 9, 8 })
3399
3400 asserterror The first argument of the function “part#” should be
3401 ... a numeric vector, not a string.
3402 a# = part# ("hello", 4, { 5, 6, 7, 9, 8 })
3403
3404 asserterror The second argument of the function “part#” should be
3405 ... a number (the starting index), not a string.
3406 a# = part# ({ 5, 6, 7, 9, 8 }, "hello", 4)
3407
3408 asserterror The second argument of the function “part#” should be
3409 ... a number (the starting index), not a numeric vector.
3410 a# = part# ({ 5, 6, 7, 9, 8 }, { 0 }, 4)
3411
3412 asserterror The third argument of the function “part#” should be
3413 ... a number (the end index), not a string.
3414 a# = part# ({ 5, 6, 7, 9, 8 }, 4, "hello")
3415
3416 asserterror The third argument of the function “part#” should be
3417 ... a number (the end index), not a numeric vector.
3418 a# = part# ({ 5, 6, 7, 9, 8 }, 4, { 0 })
3419 }
3420 Finally the checks on the preconditions of the arguments:
3421 both element numbers should be within bounds:
3422 {
3423 asserterror The second argument of the function “part#” (the starting index)
3424 ... should (after rounding) be a positive whole number, not -3.
3425 a# = part# ({ 5, 6, 7, 9, 8 }, -2.98, 0)
3426
3427 asserterror The second argument of the function “part#” (the starting index)
3428 ... should (after rounding) be a positive whole number, not 0.
3429 a# = part# ({ 5, 6, 7, 9, 8 }, 0, 0)
3430
3431 asserterror The second argument of the function “part#” (the starting index)
3432 ... should (after rounding) be at most the number of elements (5), not 99.
3433 a# = part# ({ 10, 6, 7, 9, 8 }, 99, 0)
3434
3435 asserterror The second argument of the function “part#” (the starting index)
3436 ... should (after rounding) be at most the number of elements (5), not 6.
3437 a# = part# ({ 10, 6, 7, 9, 8 }, 5.5, 0)
3438
3439 asserterror The third argument of the function “part#” (the end index)
3440 ... should (after rounding) be a positive whole number, not -3.
3441 a# = part# ({ 10, 6, 7, 9, 8 }, 3, -2.98)
3442
3443 asserterror The third argument of the function “part#” (the end index)
3444 ... should (after rounding) be a positive whole number, not 0.
3445 a# = part# ({ 10, 6, 7, 9, 8 }, 3, 0)
3446
3447 asserterror The third argument of the function “part#” (the end index)
3448 ... should (after rounding) be at most the number of elements (5), not 99.
3449 a# = part# ({ 10, 6, 7, 9, 8 }, 3, 99)
3450
3451 asserterror The third argument of the function “part#” (the end index)
3452 ... should (after rounding) be at most the number of elements (5), not 6.
3453 a# = part# ({ 10, 6, 7, 9, 8 }, 3, 5.5)
3454 }
3455
3456 ################################################################################
3457 "`part##`"
3458 © Paul Boersma 2023
3459
3460 A function that can be used in @Formulas.
3461
3462 Syntax and semantics
3463 ====================
3464 #`part##` (%`matrix#`, %`fromRow`, %`toRow`, %`fromColumn`, %`toColumn`)
3465 : compute a subwindow of cells of a matrix.
3466
3467 Examples
3468 ========
3469 {
3470 \`{assert} part## ({{ 7, 4, 9, 3 }, { 1, 4, 3, 22 }, { 0, 8, 6, 5 }},
3471 ... 2, 3, 1, 3) = {{ 1, 4, 3 }, { 0, 8, 6 }}
3472 }
3473
3474 Examples of error messages
3475 ==========================
3476 Checks on the number of arguments (always has to be 5):
3477 {
3478 asserterror The function “part##” requires exactly five arguments
3479 ... (namely a matrix, a starting row, an end row, a starting column, and an end column),
3480 ... not the 0 given.
3481 a## = part## ()
3482
3483 asserterror The function “part##” requires exactly five arguments
3484 ... (namely a matrix, a starting row, an end row, a starting column, and an end column),
3485 ... not the 7 given.
3486 a## = part## (7, 8, 9, 10, 11, "hello", "world")
3487 }
3488 Checks on the types of the arguments (always has to be matrix, number, number, number, number):
3489 {
3490 asserterror The first argument of the function “part##” should be
3491 ... a numeric matrix, not a number.
3492 a## = part## (2, 4, { 5, 6, 7, 9, 8 }, 66, 99)
3493
3494 asserterror The first argument of the function “part##” should be
3495 ... a numeric matrix, not a string.
3496 a## = part## ("hello", 4, { 5, 6, 7, 9, 8 }, 66, 99)
3497
3498 asserterror The first argument of the function “part##” should be
3499 ... a numeric matrix, not a numeric vector.
3500 a## = part## ({ 5, 6, 7, 9, 8 }, 4, { 5, 6, 7, 9, 8 }, 66, 99)
3501
3502 m## = {{ 7, 4, 9, 3 }, { 1, 4, 3, 22 }, { 0, 8, 6, 5 }} ; three rows, four columns
3503
3504 asserterror The second argument of the function “part##” should be
3505 ... a number (the starting row), not a string.
3506 a## = part## (m##, "hello", 4, 66, 99)
3507
3508 asserterror The second argument of the function “part##” should be
3509 ... a number (the starting row), not a numeric vector.
3510 a## = part## (m##, { 0 }, 4, 66, 99)
3511
3512 asserterror The third argument of the function “part##” should be
3513 ... a number (the end row), not a string.
3514 a## = part## (m##, 4, "hello", 66, 99)
3515
3516 asserterror The third argument of the function “part##” should be
3517 ... a number (the end row), not a numeric vector.
3518 a## = part## (m##, 4, { 0 }, 66, 99)
3519
3520 asserterror The fourth argument of the function “part##” should be
3521 ... a number (the starting column), not a string.
3522 a## = part## (m##, 66, 99, "hello", 4)
3523
3524 asserterror The fourth argument of the function “part##” should be
3525 ... a number (the starting column), not a numeric vector.
3526 a## = part## (m##, 66, 99, { 0 }, 4)
3527
3528 asserterror The fifth argument of the function “part##” should be
3529 ... a number (the end column), not a string.
3530 a## = part## (m##, 66, 99, 4, "hello")
3531
3532 asserterror The fifth argument of the function “part##” should be
3533 ... a number (the end column), not a numeric vector.
3534 a## = part## (m##, 66, 99, 4, { 0 })
3535 }
3536 Finally the checks on the preconditions of the arguments:
3537 both row numbers and both column numbers should be within bounds:
3538 {
3539 asserterror The second argument of the function “part##” (the starting row)
3540 ... should (after rounding) be a positive whole number, not -3.
3541 a## = part## (m##, -2.98, 0, 66, 99)
3542
3543 asserterror The second argument of the function “part##” (the starting row)
3544 ... should (after rounding) be a positive whole number, not 0.
3545 a## = part## (m##, 0, 0, 66, 99)
3546
3547 asserterror The second argument of the function “part##” (the starting row)
3548 ... should (after rounding) be at most the number of rows (3), not 99.
3549 a## = part## (m##, 99, 0, 66, 99)
3550
3551 asserterror The second argument of the function “part##” (the starting row)
3552 ... should (after rounding) be at most the number of rows (3), not 4.
3553 a## = part## (m##, 3.5, 0, 66, 99)
3554
3555 asserterror The third argument of the function “part##” (the end row)
3556 ... should (after rounding) be a positive whole number, not -3.
3557 a## = part## (m##, 2, -2.98, 66, 99)
3558
3559 asserterror The third argument of the function “part##” (the end row)
3560 ... should (after rounding) be a positive whole number, not 0.
3561 a## = part## (m##, 2, 0, 66, 99)
3562
3563 asserterror The third argument of the function “part##” (the end row)
3564 ... should (after rounding) be at most the number of rows (3), not 99.
3565 a## = part## (m##, 2, 99, 66, 99)
3566
3567 asserterror The third argument of the function “part##” (the end row)
3568 ... should (after rounding) be at most the number of rows (3), not 4.
3569 a## = part## (m##, 2, 3.5, 66, 99)
3570
3571 asserterror The fourth argument of the function “part##” (the starting column)
3572 ... should (after rounding) be a positive whole number, not -3.
3573 a## = part## (m##, 2, 3, -2.98, 0)
3574
3575 asserterror The fourth argument of the function “part##” (the starting column)
3576 ... should (after rounding) be a positive whole number, not 0.
3577 a## = part## (m##, 2, 3, 0, 0)
3578
3579 asserterror The fourth argument of the function “part##” (the starting column)
3580 ... should (after rounding) be at most the number of columns (4), not 99.
3581 a## = part## (m##, 2, 3, 99, 0)
3582
3583 asserterror The fourth argument of the function “part##” (the starting column)
3584 ... should (after rounding) be at most the number of columns (4), not 5.
3585 a## = part## (m##, 2, 3, 4.5, 0)
3586
3587 asserterror The fifth argument of the function “part##” (the end column)
3588 ... should (after rounding) be a positive whole number, not -3.
3589 a## = part## (m##, 2, 3, 1, -2.98)
3590
3591 asserterror The fifth argument of the function “part##” (the end column)
3592 ... should (after rounding) be a positive whole number, not 0.
3593 a## = part## (m##, 2, 3, 1, 0)
3594
3595 asserterror The fifth argument of the function “part##” (the end column)
3596 ... should (after rounding) be at most the number of columns (4), not 99.
3597 a## = part## (m##, 2, 3, 1, 99)
3598
3599 asserterror The fifth argument of the function “part##” (the end column)
3600 ... should (after rounding) be at most the number of columns (4), not 5.
3601 a## = part## (m##, 2, 3, 1, 4.5)
3602 }
3603
3604 ################################################################################
3605 "`pauseScript`"
3606 © Paul Boersma 2023
3607
3608 A function that can be used in @Scripting.
3609
3610 Syntax and semantics
3611 ====================
3612 #`pauseScript` (`...`)
3613 : show a message in a simple @@pause window@.
3614
3615 For details and examples, see @@Scripting 6.6. Controlling the user@.
3616
3617 ################################################################################
3618 "`percent$`"
3619 © Paul Boersma 2023
3620
3621 A function that can be used in @@Formulas@.
3622
3623 Syntax and semantics
3624 ====================
3625 #`percent$` (%`number`, %`precision`)
3626 : format a number as a string,
3627 with a trailing percent sign and %`precision` digits after the decimal point.
3628
3629 ################################################################################
3630 "`phonToDifferenceLimens`"
3631 © Paul Boersma 2002, 2023
3632
3633 A function that can be used in @@Formulas@.
3634
3635 Syntax and semantics
3636 ====================
3637 #`phonToDifferenceLimens` (%`x`)
3638 : convert a sensation level %`x` in phon units into an intensity difference limen level.
3639
3640 Definition
3641 ==========
3642 ~ `phonToDifferenceLimens` (%phon) = 30 · ((61/60)^^ %phon^ − 1)
3643
3644 Related function
3645 ================
3646 #`phonToDifferenceLimens` is the inverse of @`differenceLimensToPhon`.
3647
3648 Derivation
3649 ==========
3650
3651 In first approximation, humans can detect an intensity difference of 1 phon, i.e.
3652 if two sounds that differ only in intensity are played a short time after each other,
3653 people can generally detect their intensity difference if it is greater than 1 phon.
3654
3655 But the sensitivity is somewhat better for louder sounds.
3656 According to @@Jesteadt, Wier & Green (1977)@, the relative difference limen
3657 of intensity is given by
3658 ~ DLI = \De%I / %I = 0.463 · (%I / %I_0)^^−0.072^
3659
3660 In this formula, %I is the intensity of the sound in Watt/m^2, %I_0 is the intensity of
3661 the auditory threshold (i.e. 10^^−12^ Watt/m^2 at 1000 Hz),
3662 and \De%I is the just noticeable difference.
3663
3664 @@Boersma (1998)|Boersma (1998: 109)@ calculates a difference-limen scale from this.
3665 Given an intensity %I, the number of difference limens above threshold is
3666 ~ \in__%%I%0_^%I %dx \De%I(%x)
3667 = (1 / 0.463) \in__%%I%0_^%I %dx %I_0^^−0.072^ %x^^0.072−1^
3668 ~ = (1 / (0.463 · 0.072)) ((%I / %I_0)^^0.072^ − 1)
3669
3670 The sensation level in phon is defined as
3671 ~ SL = 10 log__10_ (%I / %I_0)
3672
3673 so that the number of difference limens above threshold is
3674 ~ (1 / (0.463 · 0.072)) (10^^(0.072 / 10) (10 log (%I / %I_0))^ − 1)
3675 = 30 · (1.0167^^SL^ − 1)
3676
3677 ################################################################################
3678 "`plusObject`"
3679 © Paul Boersma 2023
3680
3681 A function that can be used in @Formulas.
3682
3683 Syntax and semantics
3684 ====================
3685 #`plusObject` (`...`)
3686 : select the objects given by IDs and/or full names,
3687 without deselecting any objects that are currently selected.
3688
3689 ################################################################################
3690 "`procedure`"
3691 © Paul Boersma 2023
3692
3693 A keyword that can be used in @Scripting.
3694
3695 Syntax and semantics
3696 ====================
3697 #`procedure`: %`procedureName$`, `...`
3698 : start the definition of the procedure %`procedureName$`, with optional parameters.
3699
3700 For an introduction, see @@Scripting 5.5. Procedures@.
3701
3702 ################################################################################
3703 "`randomBernoulli`"
3704 © Paul Boersma 2023
3705
3706 A function that can be used in @Formulas.
3707
3708 Syntax and semantics
3709 ====================
3710 #`randomBernoulli` (%`p`)
3711 : generate a Bernoulli-distributed random deviate,
3712 which is 1 with probability %`p`, and 0 with probability 1 \-m %`p`.
3713
3714 ################################################################################
3715 "`randomBernoulli#`"
3716 © Paul Boersma 2023
3717
3718 A function that can be used in @Formulas.
3719
3720 Syntax and semantics
3721 ====================
3722 #`randomBernoulli#` (%`n`, %`p`)
3723 : generate %`n` independent Bernoulli-distributed (@`randomBernoulli`) zeroes and ones.
3724
3725 #`randomBernoulli#` (%`model#`, %`p`)
3726 : create a vector with the same number of elements as %`model#`,
3727 and fill all elements with independent Bernoulli-distributed zeroes and ones.
3728 This is shorthand for doing
3729 `
3730 \#{randomBernoulli#} (\`{size} (\%{model#}), \%{p})
3731 `
3732 ################################################################################
3733 "`randomBernoulli##`"
3734 © Paul Boersma 2023,2024
3735
3736 A function that can be used in @Formulas.
3737
3738 Syntax and semantics
3739 ====================
3740 #`randomBernoulli##` (%`nrow`, %`ncol`, %`p`)
3741 : generate %`nrow` \xx %`ncol` independent Bernoulli-distributed (@`randomBernoulli`) zeroes and ones.
3742
3743 #`randomBernoulli##` (%`model##`, %`p`)
3744 : create a matrix with the same number of rows and columns as %`model##`,
3745 and fill all cells with independent Bernoulli-distributed zeroes and ones.
3746 This is shorthand for doing
3747 `
3748 \#{randomBernoulli##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{p})
3749 `
3750 ################################################################################
3751 "`randomGamma`"
3752 © David Weenink 2019, Paul Boersma 2023
3753
3754 A function that can be used in @Formulas.
3755
3756 Syntax and semantics
3757 ====================
3758 #`randomGamma` (%`shape`, %`rate`)
3759 : generate a random number from a Gamma distribution
3760 with shape parameter %`shape` and rate parameter %`rate`, which is defined as
3761 the probability density function %f(%x; %`shape`, %`rate`) =
3762 (1 / \Ga (%`shape`)) %`rate`^^%`shape`^ %x^^%`shape`−1^ %e^^−%`rate` %`x`^,
3763 for %`x` > 0, %`shape` > 0 and %`rate` > 0,
3764 according to the method by @@Marsaglia & Tsang (2000)@.
3765
3766 ################################################################################
3767 "`randomGamma#`"
3768 © Paul Boersma 2023,2024
3769
3770 A function that can be used in @Formulas.
3771
3772 Syntax and semantics
3773 ====================
3774 #`randomGamma#` (%`n`, %`shape`, %`rate`)
3775 : generate %`n` independent \Ga-distributed (@`randomGamma`) numbers.
3776
3777 #`randomGamma#` (%`model#`, %`shape`, %`rate`)
3778 : create a vector with the same number of elements as %`model#`,
3779 and fill all elements with independent \Ga-distributed numbers.
3780 This is shorthand for doing
3781 {;
3782 \#{randomGamma#} (\`{size} (model#), \%{shape}, \%{rate})
3783 }
3784 ################################################################################
3785 "`randomGamma##`"
3786 © Paul Boersma 2023,2024
3787
3788 A function that can be used in @Formulas.
3789
3790 Syntax and semantics
3791 ====================
3792 #`randomGamma##` (%`nrow`, %`ncol`, %`shape`, %`rate`)
3793 : generate %`nrow` \xx %`ncol` independent \Ga-distributed (@`randomGamma`) numbers.
3794
3795 #`randomGamma##` (%`model##`, %`shape`, %`rate`)
3796 : create a matrix with the same number of rows and columns as %`model##`,
3797 and fill all cells with independent \Ga-distributed numbers.
3798 This is shorthand for doing
3799 {;
3800 \#{randomGammma##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{shape}, \%{rate})
3801 }
3802 ################################################################################
3803 "`randomGauss`"
3804 © Paul Boersma 2023
3805
3806 A function that can be used in @Formulas.
3807
3808 Syntax and semantics
3809 ====================
3810 #`randomGauss` (%`mu`, %`sigma`)
3811 : generate a normally distributed random deviate,
3812 with true population mean %`mu` and true population standard deviation %`sigma`.
3813
3814 ################################################################################
3815 "`randomGauss#`"
3816 © Paul Boersma 2023,2024
3817
3818 A function that can be used in @Formulas.
3819
3820 Syntax and semantics
3821 ====================
3822 #`randomGauss#` (%`n`, %`mu`, %`sigma`)
3823 : generate %`n` independent normally distributed (@`randomGauss`) numbers.
3824
3825 #`randomGauss#` (%`model#`, %`mu`, %`sigma`)
3826 : create a vector with the same number of elements as %`model#`,
3827 and fill all elements with independent normally distributed numbers.
3828 This is shorthand for doing
3829 {;
3830 \#{randomGauss#} (\`{size} (\%{model#}), \%{mu}, \%{sigma})
3831 }
3832 ################################################################################
3833 "`randomGauss##`"
3834 © Paul Boersma 2023,2024
3835
3836 A function that can be used in @Formulas.
3837
3838 Syntax and semantics
3839 ====================
3840 #`randomGauss##` (%`nrow`, %`ncol`, %`mu`, %`sigma`)
3841 : generate %`nrow` \xx %`ncol` independent normally distributed (@`randomGauss`) numbers.
3842
3843 #`randomGauss##` (%`model##`, %`mu`, %`sigma`)
3844 : create a matrix with the same number of rows and columns as %`model##`,
3845 and fill all cells with independent normally distributed numbers.
3846 This is shorthand for doing
3847 {;
3848 \#{randomGauss##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{mu}, \%{sigma})
3849 }
3850 ################################################################################
3851 "`randomImax`"
3852 © Paul Boersma 2026
3853
3854 A function that can be used in @@Formulas@.
3855
3856 Syntax and semantics
3857 ====================
3858 #`randomImax` (%`distribution#`)
3859 : sample from an array of relative probabilities.
3860
3861 Example
3862 =======
3863 The following draws the outcome 1 one half of the time, the outcome 2 one sixth of the time, and the outcome 3 one third of the time:
3864 {
3865 for i to 20
3866 outcome = \#{randomImax} ({ 3.0, 1.0, 2.0 })
3867 \`{appendInfoLine}: outcome
3868 endfor
3869 }
3870 All elements of the vector have to be non-negative:
3871 {
3872 \`{asserterror} Element 2 is less than zero; cannot interpret as a probability.
3873 a = \#{randomImax} ({ 3.0, -1.0, 2.0 })
3874 }
3875 Some elements of the vector may be zero. The following draws the outcome 1 60 percent of the time, and the outcome 3 40 percent of the time:
3876 {
3877 for i to 20
3878 outcome = \#{randomImax} ({ 3.0, 0.0, 2.0 })
3879 \`{appendInfoLine}: outcome
3880 endfor
3881 }
3882 Not all elements of the vector can be zero:
3883 {
3884 \`{asserterror} Cannot interpret a zero vector as probabilities.
3885 a = \#{randomImax} ({ 0.0, 0.0, 0.0 })
3886 }
3887
3888 ################################################################################
3889 "`randomInteger`"
3890 © Paul Boersma 2023
3891
3892 A function that can be used in @@Formulas@.
3893
3894 Syntax and semantics
3895 ====================
3896 #`randomInteger` (%`min`, %`max`)
3897 : generate a uniformly distributed integer random deviate,
3898 with minimum %`min` and maximum %`max`.
3899
3900 ################################################################################
3901 "`randomInteger#`"
3902 © Paul Boersma 2023,2024
3903
3904 A function that can be used in @@Formulas@.
3905
3906 Syntax and semantics
3907 ====================
3908 #`randomInteger#` (%`n`, %`min`, %`max`)
3909 : generates %`n` independent uniformly distributed (@`randomInteger`) integer numbers.
3910
3911 #`randomInteger#` (%`model#`, %`min`, %`max`):
3912 : create a vector with the same number of elements as %`model#`,
3913 and fill all elements with independent uniformly distributed integer numbers.
3914 This is shorthand for doing
3915 {;
3916 \#{randomInteger#} (\`{size} (\%{model#}), \%{min}, \%{max})
3917 }
3918 ################################################################################
3919 "`randomInteger##`"
3920 © Paul Boersma 2023,2024
3921
3922 A function that can be used in @@Formulas@.
3923
3924 Syntax and semantics
3925 ====================
3926 #`randomInteger##` (%`nrow`, %`ncol`, %`min`, %`max`)
3927 : generate %`nrow` \xx %`ncol` independent normally distributed (@`randomInteger`) numbers.
3928
3929 #`randomInteger##` (%`model##`, %`min`, %`max`)
3930 : create a matrix with the same number of rows and columns as %`model##`,
3931 and fill all cells with independent uniformly distributed integer numbers.
3932 This is shorthand for doing
3933 {;
3934 \#{randomInteger##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{min}, \%{max})
3935 }
3936 ################################################################################
3937 "`randomPoisson`"
3938 © Paul Boersma 2023
3939
3940 A function that can be used in @@Formulas@.
3941
3942 Syntax and semantics
3943 ====================
3944 #`randomPoisson` (%`mean`)
3945 : generate a Poisson-distributed random deviate, with true mean %`mean`.
3946
3947 ################################################################################
3948 "`randomPoisson#`"
3949 © Paul Boersma 2023,2024
3950
3951 A function that can be used in @@Formulas@.
3952
3953 Syntax and semantics
3954 ====================
3955 #`randomPoisson#` (%`n`, %`mean`)
3956 : generate %`n` independent Poisson-distributed (@`randomPoisson`) numbers.
3957
3958 #`randomPoisson#` (%`model#`, %`mean`)
3959 : create a vector with the same number of elements as %`model#`,
3960 and fill all elements with independent Poisson-distributed numbers.
3961 This is shorthand for doing
3962 {;
3963 \#{randomPoisson#} (\`{size} (\%{model#}), \%{mean})
3964 }
3965 ################################################################################
3966 "`randomPoisson##`"
3967 © Paul Boersma 2023,2024
3968
3969 A function that can be used in @@Formulas@.
3970
3971 Syntax and semantics
3972 ====================
3973 #`randomPoisson##` (%`nrow`, %`ncol`, %`mean`)
3974 : generate %`nrow` \xx %`ncol` independent Poisson-distributed (@`randomPoisson`) numbers.
3975
3976 #`randomPoisson##` (%`model##`, %`mean`)
3977 : create a matrix with the same number of rows and columns as %`model##`,
3978 and fill all cells with independent Poisson-distributed numbers.
3979 This is shorthand for doing
3980 {;
3981 \#{randomPoisson##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{mean})
3982 }
3983 ################################################################################
3984 "`randomUniform`"
3985 © Paul Boersma 2023
3986
3987 A function that can be used in @@Formulas@.
3988
3989 Syntax and semantics
3990 ====================
3991 #`randomUniform` (%`min`, %`max`)
3992 : generate a uniformly distributed random deviate,
3993 with true minimum %`min` (included) and true maximum %`max` (excluded).
3994
3995 ################################################################################
3996 "`randomUniform#`"
3997 © Paul Boersma 2023,2024
3998
3999 A function that can be used in @@Formulas@.
4000
4001 Syntax and semantics
4002 ====================
4003 #`randomUniform#` (%`n`, %`min`, %`max`)
4004 : generate %`n` independent uniformly distributed (@`randomUniform`) numbers.
4005
4006 #`randomUniform#` (%`model#`, %`min`, %`max`)
4007 : create a vector with the same number of elements as %`model#`,
4008 and fill all elements with independent uniformly distributed numbers.
4009 This is shorthand for doing
4010 {;
4011 \#{randomUniform#} (\`{size} (\%{model#}), \%{min}, \%{max})
4012 }
4013 ################################################################################
4014 "`randomUniform##`"
4015 © Paul Boersma 2023,2024
4016
4017 A function that can be used in @@Formulas@.
4018
4019 Syntax and semantics
4020 ====================
4021 #`randomUniform##` (%`nrow`, %`ncol`, %`min`, %`max`)
4022 : generate %`nrow` \xx %`ncol` independent uniformly distributed (@`randomUniform`) numbers.
4023
4024 #`randomUniform##` (%`model##`, %`min`, %`max`)
4025 : create a matrix with the same number of rows and columns as %`model##`,
4026 and fill all cells with independent uniformly distributed numbers.
4027 This is shorthand for doing
4028 {;
4029 \#{randomUniform##} (\`{numberOfRows} (\%{model##}), \`{numberOfColumns} (\%{model##}), \%{min}, \%{max})
4030 }
4031 ################################################################################
4032 "`random_initializeSafelyAndUnpredictably`"
4033 © Paul Boersma 2023
4034
4035 A function that can be used in @@Formulas@.
4036
4037 Syntax and semantics
4038 ====================
4039 #`random_initializeSafelyAndUnpredictably` ( )
4040 : undo the effects of @`random_initializeWithSeedUnsafelyButPredictably`.
4041
4042 ################################################################################
4043 "`random_initializeWithSeedUnsafelyButPredictably`"
4044 © Paul Boersma 2023,2025
4045
4046 A function that can be used in @@Formulas@.
4047
4048 Syntax and semantics
4049 ====================
4050 #`random_initializeWithSeedUnsafelyButPredictably` (%`seed`)
4051 : produce (from now on) a reproducible sequence of random numbers.
4052
4053 The effects of this function can be undone by @`random_initializeSafelyAndUnpredictably`.
4054
4055 ################################################################################
4056 "`readFile`"
4057 © Paul Boersma 2023
4058
4059 A function that can be used in @Scripting.
4060
4061 Syntax and semantics
4062 ====================
4063 #`readFile` (%`filePath$`)
4064 : read a number from a text file.
4065
4066 ################################################################################
4067 "`readFile$`"
4068 © Paul Boersma 2023
4069
4070 A function that can be used in @Scripting.
4071
4072 Syntax and semantics
4073 ====================
4074 #`readFile$` (%`filePath$`)
4075 : read a whole text file into a string.
4076
4077 ################################################################################
4078 "`readFile#`"
4079 © Paul Boersma 2023
4080
4081 A function that can be used in @Scripting.
4082
4083 Syntax and semantics
4084 ====================
4085 #`readFile#` (%`filePath$`)
4086 : read the elements of a vector from a text file.
4087
4088 The elements can be separated by horizontal and/or vertical space.
4089
4090 ################################################################################
4091 "`readFile##`"
4092 © Paul Boersma 2023
4093
4094 A function that can be used in @Scripting.
4095
4096 Syntax and semantics
4097 ====================
4098 #`readFile##` (%`filePath$`)
4099 : read the cells of a matrix from a text file.
4100
4101 Each line of the text file is read as a row of the matrix;
4102 the elements of the row are separated by horizontal space (i.e. spaces and/or tabs).
4103
4104 The matrix obtains as many rows as there are lines in the text file.
4105
4106 Precondition
4107 ============
4108 Each line of the text file should contain the same number of elements.
4109
4110 ################################################################################
4111 "`readLinesFromFile$#`"
4112 © Paul Boersma 2023
4113
4114 A function that can be used in @Scripting.
4115
4116 Syntax and semantics
4117 ====================
4118 #`readLinesFromFile$#` (%`filePath$`)
4119 : read all lines from a text file.
4120
4121 ################################################################################
4122 "`rectify`"
4123 © Paul Boersma 2023
4124
4125 A function that can be used in @Formulas.
4126
4127 Syntax and semantics
4128 ====================
4129 #`rectify` (%`x`)
4130 : return zero if %`x` is negative, and %`x` if %`x` is positive.
4131
4132 ################################################################################
4133 "`rectify#`"
4134 © Paul Boersma 2023
4135
4136 A function that can be used in @Formulas.
4137
4138 Syntax and semantics
4139 ====================
4140 #`rectify#` (%`v#`)
4141 : rectifies (@`rectify`) each element of the vector %`v#`.
4142
4143 ################################################################################
4144 "`rectify##`"
4145 © Paul Boersma 2023
4146
4147 A function that can be used in @Formulas.
4148
4149 Syntax and semantics
4150 ====================
4151 #`rectify##` (%`m##`)
4152 : rectifies (@`rectify`) each cell of the matrix %`m##`.
4153
4154 ################################################################################
4155 "`removeObject`"
4156 © Paul Boersma 2023
4157
4158 A function that can be used in @@Formulas@.
4159
4160 Syntax and semantics
4161 ====================
4162 #`removeObject` (`...`)
4163 : remove the objects given by IDs and/or full names,
4164 without (further) changing the selection.
4165
4166 ################################################################################
4167 "`repeat#`"
4168 © Paul Boersma 2023
4169
4170 A function that can be used in @Formulas.
4171
4172 Syntax and semantics
4173 ====================
4174 #`repeat#` (%`v#`, %`n`)
4175 : repeats the whole sequence of elements of %`v#` %`n` times.
4176
4177 ################################################################################
4178 "`replace$`"
4179 © Paul Boersma 2023
4180
4181 A function that can be used in @Formulas.
4182
4183 Syntax and semantics
4184 ====================
4185 #`replace$` (%`a$`, %`b$`, %`c$`, %`n`)
4186 : within %`a$`, replace the first %`n` occurrences of %`b$`
4187 with %`c$`, or all if %`n` = 0.
4188
4189 ################################################################################
4190 "`replace_regex$`"
4191 © Paul Boersma 2023
4192
4193 A function that can be used in @Formulas.
4194
4195 Syntax and semantics
4196 ====================
4197 #`replace_regex$` (%`a$`, %`b$`, %`c$`, %`n`)
4198 : within %`a$`, replaces the first %`n` matches of regular expression %`b$`
4199 with the regular expression %`c$`, or all if %`n` = 0.
4200 See @@Regular expressions@.
4201
4202 ################################################################################
4203 "`right$`"
4204 © Paul Boersma 2023
4205
4206 A function that can be used in @@Formulas@.
4207
4208 Syntax and semantics
4209 ====================
4210 #`right$` (%`string$`, %`n`)
4211 : return the %`n` last characters in %`string$`.
4212
4213 ################################################################################
4214 "`rindex`"
4215 © Paul Boersma 2023
4216
4217 A function that can be used in @@Formulas@.
4218
4219 Syntax and semantics
4220 ====================
4221 #`rindex` (%`string$`, %`part$`)
4222 : return the last location of the substring %`part$` inside %`string$`, or 0 if not found.
4223
4224 #`rindex` (%`strings$#`, %`s$`)
4225 : look up whether and where %`s$` last occurs in %`strings$`.
4226
4227 See also
4228 ========
4229 - @`index` for the %first occurrence
4230 - @`rindex_caseInsensitive` for %%case-insensitive% matching
4231 - @`rindex_regex` for %%regular-expression% matching
4232
4233 ################################################################################
4234 "`rindex_caseInsensitive`"
4235 © Paul Boersma 2023
4236
4237 A function that can be used in @@Formulas@.
4238
4239 Syntax and semantics
4240 ====================
4241 #`rindex_caseInsensitive` (%`string$`, %`part$`)
4242 : return the last location of the substring %`part$` inside %`string$`, or 0 if not found.
4243
4244 #`rindex_caseInsensitive` (%`strings$#`, %`s$`)
4245 : look up whether and where %`s$` last occurs in %`strings$#`.
4246
4247 Case insensitivity
4248 ==================
4249 For determining where the substring is located,
4250 it doesn’t matter whether %`string$` and/or %`part$` are in lower case or upper case.
4251 Here is a comparison with @`rindex`:
4252 {
4253 assert \`{rindex} ("hello", "L") = 0
4254 assert \#{rindex_caseInsensitive} ("hello", "L") = 4
4255 assert \`{rindex} ("heLlo", "L") = 3
4256 assert \#{rindex_caseInsensitive} ("heLlo", "L") = 4
4257 assert \`{rindex} ("helLo", "L") = 4
4258 assert \#{rindex_caseInsensitive} ("helLo", "L") = 4
4259 assert \`{rindex} ("heLLo", "L") = 4
4260 assert \#{rindex_caseInsensitive} ("heLLo", "L") = 4
4261 }
4262 See also
4263 ========
4264 - @`index_caseInsensitive` for the %first occurrence
4265 - @`rindex` for %%case-sensitive% matching
4266
4267 ################################################################################
4268 "`rindex_regex`"
4269 © Paul Boersma 2023
4270
4271 A function that can be used in @@Formulas@.
4272
4273 Syntax and semantics
4274 ====================
4275 #`rindex_regex` (%`string$`, %`regex$`)
4276 : return the last match of the regular expression %`regex$` inside %`string$`, or 0 if not found.
4277 See @@Regular expressions@.
4278
4279 ################################################################################
4280 "`round`"
4281 © Paul Boersma 2023-06-30
4282
4283 A function that can be used in @@Formulas@.
4284
4285 Syntax and semantics
4286 ====================
4287 #`round` (%`x`)
4288 : round %`x` to the nearest integer number.
4289
4290 {
4291 assert round (1.3) = 1
4292 assert round (1.7) = 2
4293 assert round (-1.3) = -1
4294 assert round (-1.7) = -2
4295 }
4296 Halves are rounded up:
4297 {
4298 assert round (-2.5) = -2
4299 assert round (-1.5) = -1
4300 assert round (-0.5) = 0
4301 assert round (0.5) = 1
4302 assert round (1.5) = 2
4303 assert round (2.5) = 3
4304 }
4305
4306 ################################################################################
4307 "`round#`"
4308 © Paul Boersma 2023
4309
4310 A function that can be used in @Formulas.
4311
4312 Syntax and semantics
4313 ====================
4314 #`round#` (%`v#`)
4315 : round (@`round`) each element of the vector %`v#`.
4316
4317 ################################################################################
4318 "`round##`"
4319 © Paul Boersma 2023
4320
4321 A function that can be used in @Formulas.
4322
4323 Syntax and semantics
4324 ====================
4325 #`round##` (%`m##`)
4326 : round (@`round`) each cell of the matrix %`m##`.
4327
4328 ################################################################################
4329 "`row`"
4330 © Paul Boersma 2024
4331
4332 The row number (of the current cell) in a Formula command.
4333
4334 See @@Formulas 1.7. Formulas for modification@.
4335
4336 ################################################################################
4337 "`row$`"
4338 © Paul Boersma 2024
4339
4340 The name of a row of an object.
4341
4342 Syntax and semantics
4343 ====================
4344 #`row$` [%`i`]
4345 : the name of the %%i%th row of an object.
4346
4347 See @@Formulas 8. Attributes of objects@.
4348
4349 ################################################################################
4350 "`row#`"
4351 © Paul Boersma 2024
4352
4353 A function that can be used in @Formulas.
4354
4355 Syntax and semantics
4356 ====================
4357 #`row#` (%`m##`, %`i`)
4358 : extract the %`i`th row from the matrix %`m##`.
4359
4360 Examples
4361 ========
4362 {
4363 \`{assert} row# ({{ 7, 4 }, { 99, 103 }}, 2) = { 99, 103 }
4364 }
4365
4366 ################################################################################
4367 "`rowSums#`"
4368 © Paul Boersma 2023
4369
4370 A function that can be used in @Formulas.
4371
4372 Syntax and semantics
4373 ====================
4374 #`rowSums#` (%`m##`)
4375 : compute the sum of the elements of each row of the matrix %`m##`.
4376
4377 ################################################################################
4378 "`runScript`"
4379 © Paul Boersma 2023
4380
4381 A function that can be used in @Scripting.
4382
4383 Syntax and semantics
4384 ====================
4385 #`runScript` (%`filePath$`, `...`)
4386 : run the script given by the (relative or absolute) %`filePath$`,
4387 with optional arguments given in “`...`”.
4388
4389 If there are any arguments, they will be consumed by the `form` in the script.
4390 For details and examples, see @@Scripting 6.1. Arguments to the script@.
4391
4392 ################################################################################
4393 "`runSubprocess`"
4394 © Paul Boersma 2023,2026
4395
4396 A function that can be used in @Scripting.
4397
4398 Syntax and semantics
4399 ====================
4400 #`runSubprocess` (%`executableFilePath$`, `...`)
4401 : run the program given by the (relative or absolute) %`executableFilePath$`,
4402 with optional arguments given in “`...`”.
4403
4404 If the subprocess fails in its execution, #`runSubprocess` will report
4405 the subprocess’ error message and stop the script.
4406
4407 Examples
4408 ========
4409 {;
4410 \`{writeInfoLine}: “start”
4411 \#{runSubprocess}: “C:\\Windows\Notepad.exe”
4412 \`{appendInfoLine}: “end”
4413 }
4414 This script will write “start” into the Info window, then start up `Notepad.exe`,
4415 wait until you close `Notepad`, and only then write “end” into the Info window.
4416 That is, the subprocess is run %synchronously.
4417
4418 You can use @`asynchronous` in combination with #`runSubprocess`:
4419 {;
4420 \`{writeInfoLine}: “start”
4421 \#`{asynchronous} \#{runSubprocess}: “C:\\Windows\Notepad.exe”
4422 \`{appendInfoLine}: “end”
4423 }
4424 This script will write “start” into the Info window, then start up `Notepad.exe`,
4425 and then immediately write “end” into the Info window.
4426 Whatever you subsequently do in `Notepad` (including closing that app) will have no influence on your script
4427 or on Praat in general.
4428
4429 For some more details and examples, see @@Scripting 6.5. Calling system commands@.
4430
4431 ################################################################################
4432 "`runSubprocess$`"
4433 © Paul Boersma 2023
4434
4435 A function that can be used in @Formulas.
4436
4437 Syntax and semantics
4438 ====================
4439 #`runSubprocess$` (%`executableFilePath$`, `...`)
4440 : run the program given by the (relative or absolute) %`executableFilePath$`,
4441 with optional arguments given in “`...`”, and return the output of that program.
4442
4443 For details and examples, see @@Scripting 6.5. Calling system commands@.
4444
4445 ################################################################################
4446 "`runSystem`"
4447 © Paul Boersma 2023
4448
4449 A function that can be used in @Scripting.
4450
4451 Syntax and semantics
4452 ====================
4453 #`runSystem` (`...`)
4454 : run the command line given by the arguments in “`...`”,
4455 which are plainly concatenated (in the same way as in `writeInfo`).
4456
4457 For details and examples, see @@Scripting 6.5. Calling system commands@.
4458
4459 ################################################################################
4460 "`runSystem$`"
4461 © Paul Boersma 2023
4462
4463 A function that can be used in @Scripting.
4464
4465 Syntax and semantics
4466 ====================
4467 #`runSystem$` (`...`)
4468 : run the command line given by the arguments in “`...`”,
4469 which are plainly concatenated (in the same way as in `writeInfo`),
4470 and return the output of that command line.
4471
4472 For details and examples, see @@Scripting 6.5. Calling system commands@.
4473
4474 ################################################################################
4475 "`selected`"
4476 © Paul Boersma 2023
4477
4478 A function that can be used in @Formulas.
4479
4480 Syntax and semantics
4481 ====================
4482 #`selected` ( )
4483 : return the ID of the topmost selected object.
4484
4485 #`selected` (%`i`)
4486 : return the ID of the %%i%th selected object (as counted from the top, or from the bottom if %`i` is negative).
4487
4488 #`selected` (%`type$`)
4489 : return the ID of the topmost selected object of type %`type$`.
4490
4491 #`selected` (%`type$`, %`i`)
4492 : return the ID of the %%i%th selected object of type %`type$` (as counted from the top, or from the bottom if %`i` is negative).
4493
4494 Usage
4495 =====
4496 For examples, see @@Scripting 4.3. Querying objects@.
4497
4498 ################################################################################
4499 "`selected$`"
4500 © Paul Boersma 2023
4501
4502 A function that can be used in @Formulas.
4503
4504 Syntax and semantics
4505 ====================
4506 #`selected$` ( )
4507 : return the full name (type + given name) of the topmost selected object.
4508
4509 #`selected$` (%`i`)
4510 : return the full name (type + given name) of the %%i%th selected object (as counted from the top, or from the bottom if %`i` is negative).
4511
4512 #`selected$` (%`type$`)
4513 : return the given name of the topmost selected object of type %`type$`.
4514
4515 #`selected$` (%`type$`, %`i`)
4516 : return the given name of the %%i%th selected object of type %`type$` (as counted from the top, or from the bottom if %`i` is negative).
4517
4518 Usage
4519 =====
4520 This function is useful if you want to write or draw the name of the object.
4521 For selecting an object, using @`selected` is safer,
4522 as explained in @@Scripting 4.3. Querying objects@.
4523
4524 ################################################################################
4525 "`selected#`"
4526 © Paul Boersma 2023
4527
4528 A function that can be used in @Formulas.
4529
4530 Syntax and semantics
4531 ====================
4532 #`selected#` ( )
4533 : return a list of the IDs of all currently selected objects.
4534
4535 #`selected#` (%`type$`)
4536 : return a list of the IDs of all currently selected objects of type %`type$`.
4537
4538 Example
4539 =======
4540 Assume that at the start of the following script, the list of objects is empty:
4541 {
4542 sound = Create Sound from formula: "sine377", 1, 0, 0.1, 44100,
4543 ... ~ sin (2*pi*377*x)
4544 pitch = To Pitch: 0.01, 75, 600
4545 plusObject: sound
4546 pulses = To PointProcess (cc)
4547 plusObject: sound
4548 }
4549 At this point, the list of objects will contain three objects,
4550 which will look as follows (ID, type name, given name),
4551 where the two that stand selected are given in bold:
4552 `
4553 \#{1. Sound sine377}
4554 2. Pitch sine377
4555 \#{3. PointProcess sine377_sine377}
4556 `
4557 The IDs of the two selected objects are 1 and 3, respectively,
4558 and this is what `selected#` ( ) will show:
4559 {
4560 writeInfoLine: \#{selected#} ()
4561 }
4562 We can also just list the selected Sound objects:
4563 {
4564 writeInfoLine: \#{selected#} ("Sound")
4565 }
4566 or the selected Pitch objects (there should be none):
4567 {
4568 writeInfoLine: \#{selected#} ("Pitch")
4569 }
4570 or the selected PointProcess objects:
4571 {
4572 writeInfoLine: \#{selected#} ("PointProcess")
4573 }
4574 Test
4575 ====
4576 An automated test:
4577 {
4578 \`{assert} \#{selected#} () = { 1, 3 }
4579 \`{assert} \#{selected#} ("Sound") = { 1 }
4580 \`{assert} \#{selected#} ("Pitch") = zero# (0)
4581 \`{assert} \#{selected#} ("PointProcess") = { 3 }
4582 }
4583
4584 ################################################################################
4585 "`selected$#`"
4586 © Paul Boersma 2023
4587
4588 A function that can be used in @Formulas.
4589
4590 Syntax and semantics
4591 ====================
4592 #`selected$#` ( )
4593 : return a list of the full names of all currently selected objects.
4594
4595 #`selected$#` (%`type$`)
4596 : return a list of the given names of all currently selected objects of type %`type$`.
4597
4598 Pitfall
4599 =======
4600 You cannot normally use this function to cycle through all selected objects,
4601 because if two objects happen to have the same full name,
4602 you will select the same object twice. To cycle through all selected objects,
4603 use @`selected#` instead, because the IDs are guaranteed to be unique.
4604
4605 Example
4606 =======
4607 Assume that at the start of the following script, the list of objects is empty:
4608 {
4609 sound = Create Sound from formula: "sine377", 1, 0, 0.1, 44100,
4610 ... ~ sin (2*pi*377*x)
4611 pitch = To Pitch: 0.01, 75, 600
4612 plusObject: sound
4613 pulses = To PointProcess (cc)
4614 plusObject: sound
4615 }
4616 At this point, the list of objects will contain three objects,
4617 which will look as follows (ID, type name, given name),
4618 where the two that stand selected are given in bold:
4619 `
4620 \#{1. Sound sine377}
4621 2. Pitch sine377
4622 \#{3. PointProcess sine377_sine377}
4623 `
4624 The full names of the two selected objects are `Sound sine377`
4625 and `PointProcess sine377_sine377`, respectively,
4626 and this is what `selected$#` ( ) will show:
4627 {
4628 writeInfoLine: \#{selected$#} ()
4629 }
4630 or
4631 {
4632 writeInfoLine: vertical$: \#{selected$#} ()
4633 }
4634 We can also just list the given names of the selected Sound objects:
4635 {
4636 writeInfoLine: \#{selected$#} ("Sound")
4637 }
4638 or of the selected Pitch objects (there should be none):
4639 {
4640 writeInfoLine: \#{selected$#} ("Pitch")
4641 }
4642 or of the selected PointProcess objects:
4643 {
4644 writeInfoLine: \#{selected$#} ("PointProcess")
4645 }
4646 Note that here we see only the given names (not the full names),
4647 because the type names are already known.
4648
4649 Test
4650 ====
4651 An automated test:
4652 {
4653 \`{assert} \#{selected$#} () = { “Sound sine377”,
4654 ... “PointProcess sine377_sine377” }
4655 \`{assert} \#{selected$#} ("Sound") = { “sine377” }
4656 \`{assert} \#{selected$#} ("Pitch") = empty$# (0)
4657 \`{assert} \#{selected$#} ("PointProcess") = { “sine377_sine377” }
4658 }
4659
4660 ################################################################################
4661 "`selectObject`"
4662 © Paul Boersma 2023
4663
4664 A function that can be used in @Formulas.
4665
4666 Syntax and semantics
4667 ====================
4668 #`selectObject` (`...`)
4669 : select the object(s) given by IDs and/or full names (full name = type + given name),
4670 after deselecting any objects that are currently selected.
4671
4672 ################################################################################
4673 "`semitonesToHertz`"
4674 © Paul Boersma 2023-06-30
4675
4676 A function that can be used in @Formulas.
4677
4678 Syntax and semantics
4679 ====================
4680 #`semitonesToHertz` (%`x`)
4681 : convert a value %`x` along a logarithmic acoustic scale
4682 in semitones (relative to 100 Hz) to an acoustic frequency in Hz.
4683
4684 Definition
4685 ==========
4686 ~ #`semitonesToHertz` (%x) = 100 exp (%x ln 2 / 12).
4687
4688 ################################################################################
4689 "`sigmoid`"
4690 © Paul Boersma 2023
4691
4692 A function that can be used in @@Formulas@.
4693
4694 Syntax and semantics
4695 ====================
4696 #`sigmoid` (%`x`)
4697 : compute 1 / (1 + %e^^-%`x`^) or 1 − 1 / (1 + %e^%`x`)
4698
4699 Domain and range
4700 ================
4701 #`sigmoid` (%x) is defined for all real numbers %x.
4702 The range are real values between 0 (not included) and 1 (not included).
4703
4704 ################################################################################
4705 "`sigmoid#`"
4706 © Paul Boersma 2023
4707
4708 A function that can be used in @@Formulas@.
4709
4710 Syntax and semantics
4711 ====================
4712 #`sigmoid#` (%`v#`):
4713 : compute the @`sigmoid` of each element of the vector %`v#`.
4714
4715 ################################################################################
4716 "`sigmoid##`"
4717 © Paul Boersma 2023
4718
4719 A function that can be used in @@Formulas@.
4720
4721 Syntax and semantics
4722 ====================
4723 #`sigmoid##` (%`m##`)
4724 : compute the @`sigmoid` of each cell of the matrix %`m##`.
4725
4726 ################################################################################
4727 "`sin`"
4728 © Paul Boersma 2023
4729
4730 A function that can be used in @@Formulas@.
4731
4732 Syntax and semantics
4733 ====================
4734 #`sin` (%`x`)
4735 : compute the sine of %`x`.
4736 {
4737 Axes: -5, 5, -1.1, 1.1
4738 Draw inner box
4739 Draw function: -5, 5, 1000, ~ \#{sin} (x)
4740 One mark bottom: -3*pi/2, "no", "yes", "yes", "\-m3%\pi/2"
4741 One mark bottom: -pi, "no", "yes", "yes", "\-m%\pi"
4742 One mark bottom: -pi/2, "no", "yes", "yes", "\-m%\pi/2"
4743 One mark bottom: 0, "no", "yes", "yes", "0"
4744 One mark bottom: pi/2, "no", "yes", "yes", "+%\pi/2"
4745 One mark bottom: pi, "no", "yes", "yes", "+%\pi"
4746 One mark bottom: 3*pi/2, "no", "yes", "yes", "+3%\pi/2"
4747 One mark left: -1, "no", "yes", "yes", "\-m1"
4748 One mark left: 0, "no", "yes", "yes", "0"
4749 One mark left: 1, "no", "yes", "yes", "+1"
4750 Text bottom: "yes", "%x \->"
4751 Text left: "yes", "##\#{sin}# (%x)"
4752 Text top: "no", "##just over one and a half periods of a sine wave"
4753 }
4754 This picture illustrates the following properties of the sine function:
4755
4756 - #`sin` (%x) is zero for all values of %x that are integer multiples of %\pi.
4757 - The extrema of #`sin` (%x) are \-m1 and +1.
4758 - #`sin` (%x) is \-m1 or +1 wherever %x is an odd multiple of %\pi/2.
4759 - The function is %periodic with period 2%\pi, i.e., #`sin` (%x+2%\pi) = #`sin` (%x).
4760 - The function is %symmetric around %\pi/2, i.e. #`sin` (%\pi/2\-m%x) = #`sin` (%x).
4761 - The function is %antisymmetric around 0, i.e. #`sin` (\-m%x) = \-m #`sin` (%x);
4762 in other words, if you take the sine curve and rotate it by 180 degrees
4763 around the origin (i.e. the point (0, 0)), then you get the same curve again.
4764
4765 ################################################################################
4766 "`sin#`"
4767 © Paul Boersma 2023
4768
4769 A function that can be used in @@Formulas@.
4770
4771 Syntax and semantics
4772 ====================
4773 `sin#` (%`v#`)
4774 : compute the sine (@`sin`) of each element of the vector %`v#`.
4775
4776 ################################################################################
4777 "`sin##`"
4778 © Paul Boersma 2023
4779
4780 A function that can be used in @@Formulas@.
4781
4782 Syntax and semantics
4783 ====================
4784 `sin##` (%`m##`)
4785 : compute the sine (@`sin`) of each cell of the matrix %`m##`.
4786
4787 ################################################################################
4788 "`sinc`"
4789 © Paul Boersma 2023
4790
4791 A function that can be used in @@Formulas@.
4792
4793 Syntax and semantics
4794 ====================
4795 #`sinc` (%`x`)
4796 : compute the sinus cardinalis of %`x`.
4797
4798 Definition
4799 ==========
4800 ~ #`sinc` (%x) = sin (%x) / %x
4801
4802 ################################################################################
4803 "`sincpi`"
4804 © Paul Boersma 2023
4805
4806 A function that can be used in @@Formulas@.
4807
4808 Syntax and semantics
4809 ====================
4810 #`sinc` (%`x`)
4811 : compute the sinus cardinalis (@`sinc`) of %\pi%`x`.
4812
4813 Definition
4814 ==========
4815 ~ #`sincpi` (%x) = sin (%\pi%x) / (%\pi%x)
4816
4817 ################################################################################
4818 "`sinh`"
4819 © Paul Boersma 2023
4820
4821 A function that can be used in @@Formulas@.
4822
4823 Syntax and semantics
4824 ====================
4825 #`sinh` (%`x`)
4826 : compute the hyperbolic sine of %`x`.
4827
4828 Definition
4829 ==========
4830 ~ #`sinh` (%x) = (%e^%x \-m %e^^\-m%x^) / 2
4831
4832 ################################################################################
4833 "`sinh#`"
4834 © Paul Boersma 2023
4835
4836 A function that can be used in @@Formulas@.
4837
4838 Syntax and semantics
4839 ====================
4840 #`sinh#` (%`v#`)
4841 : compute the hyperbolic sine (@`sinh`) of each element of the vector %`v#`.
4842
4843 ################################################################################
4844 "`sinh##`"
4845 © Paul Boersma 2023
4846
4847 A function that can be used in @@Formulas@.
4848
4849 Syntax and semantics
4850 ====================
4851 #`sinh##` (%`m##`)
4852 : compute the hyperbolic sine (@`sinh`) of each cell of the matrix %`m##`.
4853
4854 ################################################################################
4855 "`size`"
4856 © Paul Boersma 2023
4857
4858 A function that can be used in @@Formulas@.
4859
4860 Syntax and semantics
4861 ====================
4862 #`size` (%`v#`)
4863 : return the number of elements of the vector %`v#`.
4864
4865 ################################################################################
4866 "`shuffle#`"
4867 © Paul Boersma 2023
4868
4869 A function that can be used in @@Formulas@.
4870
4871 Syntax and semantics
4872 ====================
4873 #`shuffle#` (%`v#`)
4874 : return a vector with the same elements as %`v#`, but in randomized order.
4875
4876 ################################################################################
4877 "`shuffle$#`"
4878 © Paul Boersma 2023
4879
4880 A function that can be used in @@Formulas@.
4881
4882 Syntax and semantics
4883 ====================
4884 #`shuffle$#` (%`stringVector$#`)
4885 : return a vector with the same elements as %`stringVector$#`, but in randomized order.
4886
4887 ################################################################################
4888 "`sleep`"
4889 © Paul Boersma 2023
4890
4891 A function that can be used in @Scripting.
4892
4893 Syntax and semantics
4894 ====================
4895 #`sleep` (%`duration`)
4896 : pause the script for %`duration` seconds.
4897
4898 This can be used in animations, e.g. in the @@Demo window@.
4899
4900 ################################################################################
4901 "`softmax#`"
4902 © Paul Boersma 2023
4903
4904 A function that can be used in @@Formulas@.
4905
4906 Syntax and semantics
4907 ====================
4908 #`softmax#` (%`v#`)
4909 : convert the elements of the vector %`v` into their softmax values.
4910
4911 ################################################################################
4912 "`softmaxPerRow##`"
4913 © Paul Boersma 2023
4914
4915 A function that can be used in @@Formulas@.
4916
4917 Syntax and semantics
4918 ====================
4919 #`softmaxPerRow##` (%`m##`)
4920 : convert the elements of each row of the matrix %`m`
4921 into their softmax (@`softmax#`) values (within that row).
4922
4923 ################################################################################
4924 "`solve#`"
4925 © Paul Boersma 2023
4926
4927 See @@solving matrix equations@.
4928
4929 ################################################################################
4930 "`solve##`"
4931 © Paul Boersma 2023
4932
4933 See @@solving matrix equations@.
4934
4935 ################################################################################
4936 "`solveNonnegative#`"
4937 © Paul Boersma 2023
4938
4939 See @@solving matrix equations@.
4940
4941 ################################################################################
4942 "`solveSparse#`"
4943 © Paul Boersma 2023
4944
4945 See @@solving matrix equations@.
4946
4947 ################################################################################
4948 "`solveWeaklyConstrained#`"
4949 © Paul Boersma 2023
4950
4951 See @@solving matrix equations@.
4952
4953 ################################################################################
4954 "`sort#`"
4955 © Paul Boersma 2023
4956
4957 A function that can be used in @@Formulas@.
4958
4959 Syntax and semantics
4960 ====================
4961 #`sort#` (%`v#`)
4962 : return a vector with the same elements as %`v`, but in sorted order (from low to high).
4963
4964 ################################################################################
4965 "`sort$#`"
4966 © Paul Boersma 2023
4967
4968 A function that can be used in @@Formulas@.
4969
4970 Syntax and semantics
4971 ====================
4972 #`sort$#` (%`stringVector$#`)
4973 : return a string array with the same elements as %`stringVector$#`,
4974 but in sorted (Unicode-alphabetical) order.
4975
4976 ################################################################################
4977 "`sort_numberAware$#`"
4978 © Paul Boersma 2023
4979
4980 A function that can be used in @@Formulas@.
4981
4982 Syntax and semantics
4983 ====================
4984 #`sort_numberAware$#` (%`stringVector$#`)
4985 : return a string array with the same elements as %`stringVector$#`,
4986 but in sorted (Unicode-alphabetical) order, with special attention to numbers.
4987
4988 ################################################################################
4989 "`splitByWhitespace$#`"
4990 © Paul Boersma 2023
4991
4992 A function that can be used in @@Formulas@.
4993
4994 Syntax and semantics
4995 ====================
4996 #`splitByWhitespace$#` (%`string$`) splits a string into inks.
4997
4998 ################################################################################
4999 "`sqrt`"
5000 © Paul Boersma 2023
5001
5002 A function that can be used in @@Formulas@.
5003
5004 Syntax and semantics
5005 ====================
5006 #`sqrt` (%`x`)
5007 : take the square root of %`x`.
5008
5009 {
5010 assert sqrt (0) = 0
5011 assert sqrt (1) = 1
5012 assert sqrt (4) = 2
5013 assert sqrt (9) = 3
5014 assert (sqrt (2) - 1.41421356237309504880168872420969807856967187537694807317667973799) < 1e-17
5015 }
5016
5017 ################################################################################
5018 "`sqrt#`"
5019 © Paul Boersma 2023
5020
5021 A function that can be used in @@Formulas@.
5022
5023 Syntax and semantics
5024 ====================
5025 #sqrt#` (%`v#`)
5026 : take the square root (@`sqrt`) of each element of the vector %`v#`.
5027
5028 ################################################################################
5029 "`sqrt##`"
5030 © Paul Boersma 2023
5031
5032 A function that can be used in @@Formulas@.
5033
5034 Syntax and semantics
5035 ====================
5036 #sqrt##` (%`m##`)
5037 : take the square root (@`sqrt`) of each cell of the matrix %`m##`.
5038
5039 ################################################################################
5040 "`startsWith`"
5041 © Paul Boersma 2023
5042
5043 A function that can be used in @@Formulas@.
5044
5045 Syntax and semantics
5046 ====================
5047 #`startsWith` (%`string$`, %`part$`)
5048 : determine whether %`string$` starts with %`part$`.
5049
5050 See also
5051 ========
5052 - @`endsWith` for determining whether %`string$` %ends in %`part$`.
5053 - @`startsWith_caseInsensitive` for %%case-insensitive% matching.
5054
5055 ################################################################################
5056 "`startsWith_caseInsensitive`"
5057 © Paul Boersma 2023
5058
5059 A function that can be used in @@Formulas@.
5060
5061 Syntax and semantics
5062 ====================
5063 #`startsWith_caseInsensitive` (%`string$`, %`part$`)
5064 : determine whether %`string$` starts with %`part$`.
5065
5066 See also
5067 ========
5068 - @`endsWith_caseInsensitive` for determining whether %`string$` %ends in %`part$`.
5069 - @`startsWith` for %%case-sensitive% matching.
5070
5071 ################################################################################
5072 "`stdev`"
5073 © Paul Boersma 2023
5074
5075 A function that can be used in @@Formulas@.
5076
5077 Syntax and semantics
5078 ====================
5079 #`stdev` (%`v#`)
5080 : compute the standard deviation of the elements of the vector %`v#`.
5081
5082 ################################################################################
5083 "`stopwatch`"
5084 © Paul Boersma 2023
5085
5086 A function that can be used in @@Formulas@.
5087
5088 Syntax and semantics
5089 ====================
5090 #`stopwatch`
5091 : give the current value of the timer, which is then immediately reset to zero (note: no parentheses).
5092
5093 ################################################################################
5094 "`string$`"
5095 © Paul Boersma 2023
5096
5097 A function that can be used in @@Formulas@.
5098
5099 Syntax and semantics
5100 ====================
5101 #`string$` (%`number`)
5102 : format a number as a string.
5103
5104 ################################################################################
5105 "`studentP`"
5106 © Paul Boersma 2023
5107
5108 A function that can be used in @@Formulas@.
5109
5110 Syntax and semantics
5111 ====================
5112 #`studentP` (%`t`, %`df`)
5113 : compute the area under Student’s %T distribution from \-m\oo to %`t`.
5114
5115 ################################################################################
5116 "`studentQ`"
5117 © Paul Boersma 2023
5118
5119 A function that can be used in @@Formulas@.
5120
5121 Syntax and semantics
5122 ====================
5123 #`studentQ` (%`t`, %`df`)
5124 : compute the area under Student’s %T distribution from %`t` to +\oo.
5125
5126 ################################################################################
5127 "`sum`"
5128 © Paul Boersma 2023
5129
5130 A function that can be used in @@Formulas@.
5131
5132 Syntax and semantics
5133 ====================
5134 #`sum` (%`v#`)
5135 : compute the sum of the elements of the vector %`v`.
5136
5137 ################################################################################
5138 "`sumOver`"
5139 © Paul Boersma 2023
5140
5141 A function that can be used in @@Formulas@.
5142
5143 Syntax and semantics
5144 ====================
5145 #`sumOver` (%`loopVariable` `to` %`n`, %`numericExpressionOptionallyUsingLoopVariable`)
5146 : compute \Si_1^%`n` %`numericExpressionOptionallyUsingLoopVariable`.
5147
5148 ################################################################################
5149 "`tan`"
5150 © Paul Boersma 2023
5151
5152 A function that can be used in @@Formulas@.
5153
5154 Syntax and semantics
5155 ====================
5156 #`tan` (%`x`)
5157 : compute the tangent of %`x`.
5158
5159 Definition
5160 ==========
5161 ~ #`tan` (%x) = sin (%x) / cos (%x)
5162
5163 ################################################################################
5164 "`tan#`"
5165 © Paul Boersma 2023
5166
5167 A function that can be used in @@Formulas@.
5168
5169 Syntax and semantics
5170 ====================
5171 #`tan#` (%`v#`)
5172 : compute the tangent (@`tan`) of each element of the vector %`v#`.
5173
5174 ################################################################################
5175 "`tan##`"
5176 © Paul Boersma 2023
5177
5178 A function that can be used in @@Formulas@.
5179
5180 Syntax and semantics
5181 ====================
5182 #`tan##` (%`m##`)
5183 : compute the tangent (@`tan`) of each cell of the matrix %`m##`.
5184
5185 ################################################################################
5186 "`tanh`"
5187 © Paul Boersma 2023
5188
5189 A function that can be used in @@Formulas@.
5190
5191 Syntax and semantics
5192 ====================
5193 #`tanh` (%`x`)
5194 : compute the hyperbolic tangent of %`x`.
5195
5196 Definition
5197 ==========
5198 ~ #`tanh` (%x) = @`sinh` (%x) / @`cosh` (%x)
5199
5200 ################################################################################
5201 "`tanh#`"
5202 © Paul Boersma 2023
5203
5204 A function that can be used in @@Formulas@.
5205
5206 Syntax and semantics
5207 ====================
5208 #`tanh#` (%`v#`)
5209 : compute the hyperbolic tangent (@`tanh`) of each element of the vector %`v#`.
5210
5211 ################################################################################
5212 "`tanh##`"
5213 © Paul Boersma 2023
5214
5215 A function that can be used in @@Formulas@.
5216
5217 Syntax and semantics
5218 ====================
5219 #`tanh##` (%`m##`)
5220 : compute the hyperbolic tangent (@`tanh`) of each cell of the matrix %`m##`.
5221
5222 ################################################################################
5223 "`to#`"
5224 © Paul Boersma 2023
5225
5226 A function that can be used in @@Formulas@.
5227
5228 Syntax and semantics
5229 ====================
5230 #`to#` (%`n`)
5231 : lists the integers 1 through %`n`.
5232
5233 ################################################################################
5234 "`transpose##`"
5235 © Paul Boersma 2023
5236
5237 A function that can be used in @@Formulas@.
5238
5239 Syntax and semantics
5240 ====================
5241 #`transpose##` (%`m##`)
5242 : flip the matrix %`m##` along its diagonal.
5243
5244 ################################################################################
5245 "`truncateLeft$`"
5246 © Paul Boersma 2024
5247
5248 A function that can be used in @@Formulas@.
5249
5250 Syntax and semantics
5251 ====================
5252 #`truncateLeft$` (%`string$`, %`maximumNewWidth`)
5253 : remove characters from the left of %`string$` until the result is at least as short as %`maximumNewWidth`:
5254 {
5255 \`{assert} \#{truncateLeft$} ("hello", 3) = "llo"
5256 \`{assert} \#{truncateLeft$} ("hello", 5) = "hello"
5257 }
5258 No padding takes place, so the resulting string may be shorter than %`maximumNewWidth`:
5259 {
5260 \`{assert} \#{truncateLeft$} ("hello", 12) = "hello"
5261 }
5262 Note that %`maximumNewWidth` cannot be negative:
5263 {
5264 \`{asserterror} Can never truncate a string down to -3 characters.
5265 a$ = \#{truncateLeft$} ("hello", -3)
5266 }
5267
5268 ################################################################################
5269 "`truncateRight$`"
5270 © Paul Boersma 2024
5271
5272 A function that can be used in @@Formulas@.
5273
5274 Syntax and semantics
5275 ====================
5276 #`truncateRight$` (%`string$`, %`maximumNewWidth`)
5277 : remove characters from the left of %`string$` until the result is at least as short as %`maximumNewWidth`:
5278 {
5279 \`{assert} \#{truncateRight$} ("hello", 3) = "hel"
5280 \`{assert} \#{truncateRight$} ("hello", 5) = "hello"
5281 }
5282 No padding takes place, so the resulting string may be shorter than %`maximumNewWidth`:
5283 {
5284 \`{assert} \#{truncateRight$} ("hello", 12) = "hello"
5285 }
5286 Note that %`maximumNewWidth` cannot be negative:
5287 {
5288 \`{asserterror} Can never truncate a string down to -3 characters.
5289 a$ = \#{truncateRight$} ("hello", -3)
5290 }
5291
5292 ################################################################################
5293 "`tryToAppendFile`"
5294 © Paul Boersma 2023
5295
5296 A function that can be used in @Scripting.
5297
5298 Syntax and semantics
5299 ====================
5300 #`tryToAppendFile` (%`filePath$`)
5301 : check whether this file can be appended to.
5302
5303 The file is opened for appending, then closed
5304 (if the file already existed, it is not changed).
5305
5306 Return value
5307 ============
5308 Upon success (i.e. the file already existed and can be appended to,
5309 or the file didn’t exist yet but was successfully created), this function returns 1 (true).
5310 Otherwise, the function returns 0 (false); this can happen
5311 if the folder in the path does not exist,
5312 or if the file is (or would be) on a read-only device.
5313
5314 For instance, if my TIMIT database is in a read-only disk image called `TIMIT.dmg`,
5315 and I mounted that disk image on my Mac (by double-clicking `TIMIT.dmg`), then trying
5316 {;
5317 \#{tryToAppendFile} ("/Volumes/TIMIT/readme.doc")
5318 }
5319 would return 0.
5320
5321 Related function
5322 ================
5323 For a non-destructive version of this function, see `tryToWriteFile`.
5324
5325 ################################################################################
5326 "`tryToWriteFile`"
5327 © Paul Boersma 2023
5328
5329 A function that can be used in @Scripting.
5330
5331 Syntax and semantics
5332 ====================
5333 #`tryToWriteFile` (%`filePath$`)
5334 : check whether this file can be written to.
5335
5336 The file is opened for writing, then closed
5337 (if the file already existed, it is emptied!).
5338
5339 Return value
5340 ============
5341 Upon success (i.e. the file already existed and was successfully emptied,
5342 or the file didn’t exist yet but was successfully created), this function returns 1 (true).
5343 Otherwise, the function returns 0 (false); this can happen
5344 if the folder in the path does not exist,
5345 or if the file is (or would be) on a read-only device.
5346
5347 For instance, if my TIMIT database is in a read-only disk image called `TIMIT.dmg`,
5348 and I mounted that disk image on my Mac (by double-clicking `TIMIT.dmg`), then trying
5349 {;
5350 \#{tryToWriteFile} ("/Volumes/TIMIT/hello.txt")
5351 }
5352 would return 0.
5353
5354 Related function
5355 ================
5356 For a non-destructive version of this function, see `tryToAppendFile`.
5357
5358 ################################################################################
5359 "`unicode`"
5360 © Paul Boersma 2023
5361
5362 A function that can be used in @@Formulas@.
5363
5364 Syntax and semantics
5365 ====================
5366 #`unicode` (%`c$`)
5367 : return the Unicode codepoint number that corresponds to the character %`c$`.
5368
5369 ################################################################################
5370 "`unicode$`"
5371 © Paul Boersma 2023
5372
5373 A function that can be used in @Formulas.
5374
5375 Syntax and semantics
5376 ====================
5377 #`unicode$` (%`n`)
5378 : return the character that corresponds to the Unicode codepoint %`n`.
5379
5380 ################################################################################
5381 "`unicodeToBackslashTrigraphs$`"
5382 © Paul Boersma 2023
5383
5384 A function that can be used in @Formulas.
5385
5386 Syntax and semantics
5387 ====================
5388 #`unicodeToBackslashTrigraphs$` (%`string$`)
5389 : convert from unicode characters to backslash trigraphs,
5390 e.g. from “\ct” to “\bsct”.
5391
5392 ################################################################################
5393 "`upperCase$`"
5394 © Paul Boersma 2025
5395
5396 A function that can be used in @@Formulas@. It turns all lower-case characters
5397 into capitals.
5398
5399 Syntax and semantics
5400 ====================
5401 #`upperCase$` (%`string$`)
5402 : give the upper-case version of %`string$`, whereby all lower-case letters
5403 have been replaced with upper-case letters.
5404
5405 Tests
5406 =====
5407 {
5408 \`{assert} \#{upperCase$} ("HOwAREYou") = "HOWAREYOU"
5409 \`{assert} \#{upperCase$} ("Maria Ressa") = "MARIA RESSA"
5410 \`{assert} \#{upperCase$} ("e.g.") = "E.G."
5411 \`{assert} \#{upperCase$} ("öav") = "ÖAV"
5412 \`{assert} \#{upperCase$} ("touché") = "TOUCHÉ"
5413 }
5414
5415 ################################################################################
5416 "`upperCaseAppName$`"
5417 © Paul Boersma 2024
5418
5419 A function that can be used in @@Formulas@. The name of the present app,
5420 in upper camel case, such as `Praat` or `PraatForHospitals`.
5421
5422 Syntax and semantics
5423 ====================
5424 #`upperCaseAppName$` ( )
5425 : give the name of the present app, in upper camel case.
5426
5427 Examples
5428 ========
5429 {
5430 writeInfoLine: \#{upperCaseAppName$} ( )
5431 }
5432
5433 ################################################################################
5434 "`variableExists`"
5435 © Paul Boersma 2023
5436
5437 A function that can be used in @Scripting.
5438
5439 Syntax and semantics
5440 ====================
5441 #`variableExists` (%`variableName$`)
5442 : return 1 (true) if the variable %`variableName$` exists, else 0 (false).
5443
5444 ################################################################################
5445 "`vertical$`"
5446 © Paul Boersma 2023
5447
5448 A function that can be used in @Formulas.
5449
5450 Syntax and semantics
5451 ====================
5452 #`vertical$` (%`stringArray$#`)
5453 : format a string array as a vertical column of strings,
5454 by concatenating the elements while separating them by newlines.
5455
5456 ################################################################################
5457 "`writeFile`"
5458 © Paul Boersma 2023
5459
5460 A function that writes its arguments (texts, numbers, vectors and so on) to a new file.
5461 If the file already existed, anything that was previously present in the file is overwritten.
5462
5463 Examples of use:
5464 ================
5465
5466 ################################################################################
5467 "`writeFileLine`"
5468 © Paul Boersma 2023
5469
5470 A function that writes its arguments (texts, numbers, vectors and so on, plus a newline symbol, to a new file.
5471 If the file alreasdy existed, anything that was previously present in the file is overwritten.
5472
5473 Examples of use:
5474 ================
5475
5476 ################################################################################
5477 "`writeInfo`"
5478 © Paul Boersma 2023
5479
5480 A function that writes its arguments to the Info window,
5481 overwriting what was previously present in the Info window.
5482
5483 Examples of use:
5484 ================
5485
5486 ################################################################################
5487 "`writeInfoLine`"
5488 © Paul Boersma 2023
5489
5490 A function that writes its arguments to the Info window,
5491 overwriting what was previously present in the Info window,
5492 and moving the output cursor to the next line.
5493
5494 Examples of use:
5495 ================
5496
5497 ################################################################################
5498 "`x`"
5499 © Paul Boersma 2024
5500
5501 The horizontal place (in world coordinates) of the current cell in a Formula command.
5502
5503 See @@Formulas 1.7. Formulas for modification@.
5504
5505 ################################################################################
5506 "`xmax`"
5507 © Paul Boersma 2024
5508
5509 The top of the horizontal domain of an object, in world coordinates.
5510
5511 See @@Formulas 8. Attributes of objects@.
5512
5513 ################################################################################
5514 "`xmin`"
5515 © Paul Boersma 2024
5516
5517 The bottom of the horizontal domain of an object, in world coordinates.
5518
5519 See @@Formulas 8. Attributes of objects@.
5520
5521 ################################################################################
5522 "`y`"
5523 © Paul Boersma 2024
5524
5525 The vertical place (in world coordinates) of the current cell in a Formula command.
5526
5527 See @@Formulas 1.7. Formulas for modification@.
5528
5529 ################################################################################
5530 "`ymax`"
5531 © Paul Boersma 2024
5532
5533 The top of the vertical domain of an object, in world coordinates.
5534
5535 See @@Formulas 8. Attributes of objects@.
5536
5537 ################################################################################
5538 "`ymin`"
5539 © Paul Boersma 2024
5540
5541 The bottom of the vertical domain of an object, in world coordinates.
5542
5543 See @@Formulas 8. Attributes of objects@.
5544
5545 ################################################################################
5546 "`zero#`"
5547 © Paul Boersma 2023
5548
5549 A function that can be used in @@Formulas@.
5550
5551 Syntax and semantics
5552 ====================
5553 #`zero#` (%`n`)
5554 : return a vector with %`n` elements that are all 0.0.
5555
5556 ################################################################################
5557 "`zero##`"
5558 © Paul Boersma 2023
5559
5560 A function that can be used in @@Formulas@.
5561
5562 Syntax and semantics
5563 ====================
5564 #`zero##` (%`nrow`, %`ncol`)
5565 : return a matrix with %`nrow` \xx %`ncol` cells that are all 0.0.
5566
5567 ################################################################################
5568 )~~~"
5569 MAN_PAGES_END
5570
5571 }
5572
5573 /* End of file manual_functions.cpp */