1 @c PSPP - a program for statistical analysis.
2 @c Copyright (C) 2017 Free Software Foundation, Inc.
3 @c Permission is granted to copy, distribute and/or modify this document
4 @c under the terms of the GNU Free Documentation License, Version 1.3
5 @c or any later version published by the Free Software Foundation;
6 @c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
7 @c A copy of the license is included in the section entitled "GNU
8 @c Free Documentation License".
10 @c Use @func when refering to a function.
11 @c Use @deftypefn for their definitions
17 @chapter Mathematical Expressions
18 @cindex expressions, mathematical
19 @cindex mathematical expressions
21 Expressions share a common syntax each place they appear in @pspp{}
22 commands. Expressions are made up of @dfn{operands}, which can be
23 numbers, strings, or variable names, separated by @dfn{operators}.
24 There are five types of operators: grouping, arithmetic, logical,
25 relational, and functions.
27 Every operator takes one or more operands as input and yields exactly
28 one result as output. Depending on the operator, operands accept
29 strings or numbers as operands. With few exceptions, operands may be
30 full-fledged expressions in themselves.
33 * Boolean Values:: Boolean values
34 * Missing Values in Expressions:: Using missing values in expressions
35 * Grouping Operators:: parentheses
36 * Arithmetic Operators:: add sub mul div pow
37 * Logical Operators:: AND NOT OR
38 * Relational Operators:: EQ GE GT LE LT NE
39 * Functions:: More-sophisticated operators
40 * Order of Operations:: Operator precedence
44 @section Boolean Values
46 @cindex values, Boolean
48 Some @pspp{} operators and expressions work with Boolean values, which
49 represent true/false conditions. Booleans have only three possible
50 values: 0 (false), 1 (true), and system-missing (unknown).
51 System-missing is neither true nor false and indicates that the true
54 Boolean-typed operands or function arguments must take on one of these
55 three values. Other values are considered false, but provoke a warning
56 when the expression is evaluated.
58 Strings and Booleans are not compatible, and neither may be used in
61 @node Missing Values in Expressions
62 @section Missing Values in Expressions
64 Most numeric operators yield system-missing when given any
65 system-missing operand. A string operator given any system-missing
66 operand typically results in the empty string. Exceptions are listed
67 under particular operator descriptions.
69 String user-missing values are not treated specially in expressions.
71 User-missing values for numeric variables are always transformed into
72 the system-missing value, except inside the arguments to the
73 @code{VALUE} and @code{SYSMIS} functions.
75 The missing-value functions can be used to precisely control how missing
76 values are treated in expressions. @xref{Missing Value Functions}, for
79 @node Grouping Operators
80 @section Grouping Operators
83 @cindex grouping operators
84 @cindex operators, grouping
86 Parentheses (@samp{()}) are the grouping operators. Surround an
87 expression with parentheses to force early evaluation.
89 Parentheses also surround the arguments to functions, but in that
90 situation they act as punctuators, not as operators.
92 @node Arithmetic Operators
93 @section Arithmetic Operators
94 @cindex operators, arithmetic
95 @cindex arithmetic operators
97 The arithmetic operators take numeric operands and produce numeric
103 @item @var{a} + @var{b}
104 Yields the sum of @var{a} and @var{b}.
108 @item @var{a} - @var{b}
109 Subtracts @var{b} from @var{a} and yields the difference.
112 @cindex multiplication
113 @item @var{a} * @var{b}
114 Yields the product of @var{a} and @var{b}. If either @var{a} or
115 @var{b} is 0, then the result is 0, even if the other operand is
120 @item @var{a} / @var{b}
121 Divides @var{a} by @var{b} and yields the quotient. If @var{a} is 0,
122 then the result is 0, even if @var{b} is missing. If @var{b} is zero,
123 the result is system-missing.
126 @cindex exponentiation
127 @item @var{a} ** @var{b}
128 Yields the result of raising @var{a} to the power @var{b}. If
129 @var{a} is negative and @var{b} is not an integer, the result is
130 system-missing. The result of @code{0**0} is system-missing as well.
135 Reverses the sign of @var{a}.
138 @node Logical Operators
139 @section Logical Operators
140 @cindex logical operators
141 @cindex operators, logical
146 @cindex values, system-missing
147 @cindex system-missing
148 The logical operators take logical operands and produce logical
149 results, meaning ``true or false.'' Logical operators are
150 not true Boolean operators because they may also result in a
151 system-missing value. @xref{Boolean Values}, for more information.
156 @cindex intersection, logical
157 @cindex logical intersection
158 @item @var{a} AND @var{b}
159 @itemx @var{a} & @var{b}
160 True if both @var{a} and @var{b} are true, false otherwise. If one
161 operand is false, the result is false even if the other is missing. If
162 both operands are missing, the result is missing.
166 @cindex union, logical
167 @cindex logical union
168 @item @var{a} OR @var{b}
169 @itemx @var{a} | @var{b}
170 True if at least one of @var{a} and @var{b} is true. If one operand is
171 true, the result is true even if the other operand is missing. If both
172 operands are missing, the result is missing.
176 @cindex inversion, logical
177 @cindex logical inversion
180 True if @var{a} is false. If the operand is missing, then the result
184 @node Relational Operators
185 @section Relational Operators
187 The relational operators take numeric or string operands and produce Boolean
190 Strings cannot be compared to numbers. When strings of different
191 lengths are compared, the shorter string is right-padded with spaces
192 to match the length of the longer string.
194 The results of string comparisons, other than tests for equality or
195 inequality, depend on the character set in use. String comparisons
199 @cindex equality, testing
200 @cindex testing for equality
203 @item @var{a} EQ @var{b}
204 @itemx @var{a} = @var{b}
205 True if @var{a} is equal to @var{b}.
207 @cindex less than or equal to
210 @item @var{a} LE @var{b}
211 @itemx @var{a} <= @var{b}
212 True if @var{a} is less than or equal to @var{b}.
217 @item @var{a} LT @var{b}
218 @itemx @var{a} < @var{b}
219 True if @var{a} is less than @var{b}.
221 @cindex greater than or equal to
224 @item @var{a} GE @var{b}
225 @itemx @var{a} >= @var{b}
226 True if @var{a} is greater than or equal to @var{b}.
231 @item @var{a} GT @var{b}
232 @itemx @var{a} > @var{b}
233 True if @var{a} is greater than @var{b}.
235 @cindex inequality, testing
236 @cindex testing for inequality
240 @item @var{a} NE @var{b}
241 @itemx @var{a} ~= @var{b}
242 @itemx @var{a} <> @var{b}
243 True if @var{a} is not equal to @var{b}.
255 @cindex names, of functions
256 @pspp{} functions provide mathematical abilities above and beyond
257 those possible using simple operators. Functions have a common
258 syntax: each is composed of a function name followed by a left
259 parenthesis, one or more arguments, and a right parenthesis.
261 Function names are not reserved. Their names are specially treated
262 only when followed by a left parenthesis, so that @samp{EXP(10)}
263 refers to the constant value @math{e} raised to the 10th power, but
264 @samp{EXP} by itself refers to the value of a variable called @code{EXP}.
266 The sections below describe each function in detail.
269 * Mathematics:: EXP LG10 LN LNGAMMA SQRT
270 * Miscellaneous Mathematics:: ABS MOD MOD10 RND TRUNC
271 * Trigonometry:: ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
272 * Missing Value Functions:: MISSING NMISS NVALID SYSMIS VALUE
273 * Set Membership:: ANY RANGE
274 * Statistical Functions:: CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE
275 * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
276 REPLACE RINDEX RPAD RTRIM STRING STRUNC SUBSTR
278 * Time and Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
280 * Miscellaneous Functions:: LAG YRMODA VALUELABEL
281 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
285 @subsection Mathematical Functions
286 @cindex mathematics, advanced
288 Advanced mathematical functions take numeric arguments and produce
291 @deftypefn {Function} {} EXP (@var{exponent})
292 Returns @math{e} (approximately 2.71828) raised to power @var{exponent}.
296 @deftypefn {Function} {} LG10 (@var{number})
297 Takes the base-10 logarithm of @var{number}. If @var{number} is
298 not positive, the result is system-missing.
301 @deftypefn {Function} {} LN (@var{number})
302 Takes the base-@math{e} logarithm of @var{number}. If @var{number} is
303 not positive, the result is system-missing.
306 @deftypefn {Function} {} LNGAMMA (@var{number})
307 Yields the base-@math{e} logarithm of the complete gamma of @var{number}.
308 If @var{number} is a negative integer, the result is system-missing.
312 @deftypefn {Function} {} SQRT (@var{number})
313 Takes the square root of @var{number}. If @var{number} is negative,
314 the result is system-missing.
317 @node Miscellaneous Mathematics
318 @subsection Miscellaneous Mathematical Functions
319 @cindex mathematics, miscellaneous
321 Miscellaneous mathematical functions take numeric arguments and produce
324 @cindex absolute value
325 @deftypefn {Function} {} ABS (@var{number})
326 Results in the absolute value of @var{number}.
330 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
331 Returns the remainder (modulus) of @var{numerator} divided by
332 @var{denominator}. If @var{numerator} is 0, then the result is 0,
333 even if @var{denominator} is missing. If @var{denominator} is 0, the
334 result is system-missing.
337 @cindex modulus, by 10
338 @deftypefn {Function} {} MOD10 (@var{number})
339 Returns the remainder when @var{number} is divided by 10. If
340 @var{number} is negative, MOD10(@var{number}) is negative or zero.
344 @deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
345 Rounds @var{number} and rounds it to a multiple of @var{mult} (by
346 default 1). Halves are rounded away from zero, as are values that
347 fall short of halves by less than @var{fuzzbits} of errors in the
348 least-significant bits of @var{number}. If @var{fuzzbits} is not
349 specified then the default is taken from SET FUZZBITS (@pxref{SET
350 FUZZBITS}), which is 6 unless overridden.
354 @deftypefn {Function} {} TRUNC (@var{number} [, @var{mult}[, @var{fuzzbits}]])
355 Rounds @var{number} to a multiple of @var{mult}, toward zero. For the
356 default @var{mult} of 1, this is equivalent to discarding the
357 fractional part of @var{number}. Values that fall short of a multiple
358 of @var{mult} by less than @var{fuzzbits} of errors in the
359 least-significant bits of @var{number} are rounded away from zero. If
360 @var{fuzzbits} is not specified then the default is taken from SET
361 FUZZBITS (@pxref{SET FUZZBITS}), which is 6 unless overridden.
365 @subsection Trigonometric Functions
368 Trigonometric functions take numeric arguments and produce numeric
372 @cindex inverse cosine
373 @deftypefn {Function} {} ARCOS (@var{number})
374 @deftypefnx {Function} {} ACOS (@var{number})
375 Takes the arccosine, in radians, of @var{number}. Results in
376 system-missing if @var{number} is not between -1 and 1 inclusive.
377 This function is a @pspp{} extension.
382 @deftypefn {Function} {} ARSIN (@var{number})
383 @deftypefnx {Function} {} ASIN (@var{number})
384 Takes the arcsine, in radians, of @var{number}. Results in
385 system-missing if @var{number} is not between -1 and 1 inclusive.
389 @cindex inverse tangent
390 @deftypefn {Function} {} ARTAN (@var{number})
391 @deftypefnx {Function} {} ATAN (@var{number})
392 Takes the arctangent, in radians, of @var{number}.
396 @deftypefn {Function} {} COS (@var{angle})
397 Takes the cosine of @var{angle} which should be in radians.
401 @deftypefn {Function} {} SIN (@var{angle})
402 Takes the sine of @var{angle} which should be in radians.
406 @deftypefn {Function} {} TAN (@var{angle})
407 Takes the tangent of @var{angle} which should be in radians.
408 Results in system-missing at values
409 of @var{angle} that are too close to odd multiples of @math{\pi/2}.
413 @node Missing Value Functions
414 @subsection Missing-Value Functions
415 @cindex missing values
416 @cindex values, missing
417 @cindex functions, missing-value
419 Missing-value functions take various numeric arguments and yield
420 various types of results. Except where otherwise stated below, the
421 normal rules of evaluation apply within expression arguments to these
422 functions. In particular, user-missing values for numeric variables
423 are converted to system-missing values.
425 @deftypefn {Function} {} MISSING (@var{expr})
426 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
429 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
430 Each argument must be a numeric expression. Returns the number of
431 system-missing values in the list, which may include variable ranges
432 using the @code{@var{var1} TO @var{var2}} syntax.
435 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
436 Each argument must be a numeric expression. Returns the number of
437 values in the list that are not system-missing. The list may include
438 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
441 @deftypefn {Function} {} SYSMIS (@var{expr})
442 When @var{expr} is simply the name of a numeric variable, returns 1 if
443 the variable has the system-missing value, 0 if it is user-missing or
444 not missing. If given @var{expr} takes another form, results in 1 if
445 the value is system-missing, 0 otherwise.
448 @deftypefn {Function} {} VALUE (@var{variable})
449 Prevents the user-missing values of @var{variable} from being
450 transformed into system-missing values, and always results in the
451 actual value of @var{variable}, whether it is valid, user-missing, or
456 @subsection Set-Membership Functions
457 @cindex set membership
458 @cindex membership, of set
460 Set membership functions determine whether a value is a member of a set.
461 They take a set of numeric arguments or a set of string arguments, and
462 produce Boolean results.
464 String comparisons are performed according to the rules given in
465 @ref{Relational Operators}.
467 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
468 Results in true if @var{value} is equal to any of the @var{set}
469 values. Otherwise, results in false. If @var{value} is
470 system-missing, returns system-missing. System-missing values in
471 @var{set} do not cause @func{ANY} to return system-missing.
474 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
475 Results in true if @var{value} is in any of the intervals bounded by
476 @var{low} and @var{high} inclusive. Otherwise, results in false.
477 Each @var{low} must be less than or equal to its corresponding
478 @var{high} value. @var{low} and @var{high} must be given in pairs.
479 If @var{value} is system-missing, returns system-missing.
480 System-missing values in @var{set} do not cause @func{RANGE} to return
484 @node Statistical Functions
485 @subsection Statistical Functions
486 @cindex functions, statistical
489 Statistical functions compute descriptive statistics on a list of
490 values. Some statistics can be computed on numeric or string values;
491 other can only be computed on numeric values. Their results have the
492 same type as their arguments. The current case's weighting factor
493 (@pxref{WEIGHT}) has no effect on statistical functions.
495 These functions' argument lists may include entire ranges of variables
496 using the @code{@var{var1} TO @var{var2}} syntax.
498 @cindex arguments, minimum valid
499 @cindex minimum valid number of arguments
500 Unlike most functions, statistical functions can return non-missing
501 values even when some of their arguments are missing. Most
502 statistical functions, by default, require only 1 non-missing value to
503 have a non-missing return, but @func{CFVAR}, @func{SD}, and @func {VARIANCE} require 2.
504 These defaults can be increased (but not decreased) by appending a dot
505 and the minimum number of valid arguments to the function name. For
506 example, @subcmd{MEAN.3(X, Y, Z)} would only return non-missing if all
507 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
509 @cindex coefficient of variation
510 @cindex variation, coefficient of
511 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
512 Results in the coefficient of variation of the values of @var{number}.
513 (The coefficient of variation is the standard deviation divided by the
518 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
519 Results in the value of the greatest @var{value}. The @var{value}s may
520 be numeric or string.
524 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
525 Results in the mean of the values of @var{number}.
529 @deftypefn {Function} {} MEDIAN (@var{number}, @var{number}[, @dots{}])
530 Results in the median of the values of @var{number}. Given an even
531 number of nonmissing arguments, yields the mean of the two middle
536 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
537 Results in the value of the least @var{value}. The @var{value}s may
538 be numeric or string.
541 @cindex standard deviation
542 @cindex deviation, standard
543 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
544 Results in the standard deviation of the values of @var{number}.
548 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
549 Results in the sum of the values of @var{number}.
553 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
554 Results in the variance of the values of @var{number}.
557 @node String Functions
558 @subsection String Functions
559 @cindex functions, string
560 @cindex string functions
562 String functions take various arguments and return various results.
564 @cindex concatenation
565 @cindex strings, concatenation of
566 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
567 Returns a string consisting of each @var{string} in sequence.
568 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
569 The resultant string is truncated to a maximum of 255 characters.
572 @cindex searching strings
573 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
574 Returns a positive integer indicating the position of the first
575 occurrence of @var{needle} in @var{haystack}. Returns 0 if @var{haystack}
576 does not contain @var{needle}. Returns system-missing if @var{needle}
580 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
581 Divides @var{needles} into one or more needles, each with length
583 Searches @var{haystack} for the first occurrence of each needle, and
584 returns the smallest value. Returns 0 if @var{haystack} does not
585 contain any part in @var{needle}. It is an error if @var{needle_len}
586 does not evenly divide the length of @var{needles}. Returns
587 system-missing if @var{needles} is an empty string.
590 @cindex strings, finding length of
591 @deftypefn {Function} {} LENGTH (@var{string})
592 Returns the number of characters in @var{string}.
595 @cindex strings, case of
596 @deftypefn {Function} {} LOWER (@var{string})
597 Returns a string identical to @var{string} except that all uppercase
598 letters are changed to lowercase letters. The definitions of
599 ``uppercase'' and ``lowercase'' are system-dependent.
602 @cindex strings, padding
603 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
604 If @var{string} is at least @var{length} characters in length, returns
605 @var{string} unchanged. Otherwise, returns @var{string} padded with
606 spaces on the left side to length @var{length}. Returns an empty string
607 if @var{length} is system-missing, negative, or greater than 255.
610 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
611 If @var{string} is at least @var{length} characters in length, returns
612 @var{string} unchanged. Otherwise, returns @var{string} padded with
613 @var{padding} on the left side to length @var{length}. Returns an empty
614 string if @var{length} is system-missing, negative, or greater than 255, or
615 if @var{padding} does not contain exactly one character.
618 @cindex strings, trimming
619 @cindex white space, trimming
620 @deftypefn {Function} {} LTRIM (@var{string})
621 Returns @var{string}, after removing leading spaces. Other white space,
622 such as tabs, carriage returns, line feeds, and vertical tabs, is not
626 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
627 Returns @var{string}, after removing leading @var{padding} characters.
628 If @var{padding} does not contain exactly one character, returns an
632 @cindex numbers, converting from strings
633 @cindex strings, converting to numbers
634 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
635 Returns the number produced when @var{string} is interpreted according
636 to format specifier @var{format}. If the format width @var{w} is less
637 than the length of @var{string}, then only the first @var{w}
638 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
639 and @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
640 greater than @var{string}'s length, then it is treated as if it were
641 right-padded with spaces. If @var{string} is not in the correct
642 format for @var{format}, system-missing is returned.
645 @cindex strings, replacing substrings
646 @cindex replacing substrings
647 @deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
648 Returns string @var{haystack} with instances of @var{needle} replaced
649 by @var{replacement}. If nonnegative integer @var{n} is specified, it
650 limits the maximum number of replacements; otherwise, all instances of
651 @var{needle} are replaced.
654 @cindex strings, searching backwards
655 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle})
656 Returns a positive integer indicating the position of the last
657 occurrence of @var{needle} in @var{haystack}. Returns 0 if
658 @var{haystack} does not contain @var{needle}. Returns system-missing if
659 @var{needle} is an empty string.
662 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
663 Divides @var{needle} into parts, each with length @var{needle_len}.
664 Searches @var{haystack} for the last occurrence of each part, and
665 returns the largest value. Returns 0 if @var{haystack} does not contain
666 any part in @var{needle}. It is an error if @var{needle_len} does not
667 evenly divide the length of @var{needle}. Returns system-missing
668 if @var{needle} is an empty string or if needle_len is less than 1.
671 @cindex padding strings
672 @cindex strings, padding
673 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
674 If @var{string} is at least @var{length} characters in length, returns
675 @var{string} unchanged. Otherwise, returns @var{string} padded with
676 spaces on the right to length @var{length}. Returns an empty string if
677 @var{length} is system-missing, negative, or greater than 255.
680 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
681 If @var{string} is at least @var{length} characters in length, returns
682 @var{string} unchanged. Otherwise, returns @var{string} padded with
683 @var{padding} on the right to length @var{length}. Returns an empty
684 string if @var{length} is system-missing, negative, or greater than 255,
685 or if @var{padding} does not contain exactly one character.
688 @cindex strings, trimming
689 @cindex white space, trimming
690 @deftypefn {Function} {} RTRIM (@var{string})
691 Returns @var{string}, after removing trailing spaces. Other types of
692 white space are not removed.
695 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
696 Returns @var{string}, after removing trailing @var{padding} characters.
697 If @var{padding} does not contain exactly one character, returns an
701 @cindex strings, converting from numbers
702 @cindex numbers, converting to strings
703 @deftypefn {Function} {} STRING (@var{number}, @var{format})
704 Returns a string corresponding to @var{number} in the format given by
705 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
706 has the value @code{"123.6"}.
709 @cindex strings, trimming
710 @cindex strings, truncating
711 @cindex white space, trimming
712 @deftypefn {Function} {} STRUNC (@var{string}, @var{n})
713 Returns @var{string}, first trimming it to at most @var{n} bytes, then
714 removing trailing spaces. Returns an empty string if @var{n} is
719 @cindex strings, taking substrings of
720 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
721 Returns a string consisting of the value of @var{string} from position
722 @var{start} onward. Returns an empty string if @var{start} is system-missing,
723 less than 1, or greater than the length of @var{string}.
726 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
727 Returns a string consisting of the first @var{count} characters from
728 @var{string} beginning at position @var{start}. Returns an empty string
729 if @var{start} or @var{count} is system-missing, if @var{start} is less
730 than 1 or greater than the number of characters in @var{string}, or if
731 @var{count} is less than 1. Returns a string shorter than @var{count}
732 characters if @var{start} + @var{count} - 1 is greater than the number
733 of characters in @var{string}. Examples: @code{SUBSTR("abcdefg", 3, 2)}
734 has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
738 @cindex case conversion
739 @cindex strings, case of
740 @deftypefn {Function} {} UPCASE (@var{string})
741 Returns @var{string}, changing lowercase letters to uppercase letters.
745 @subsection Time & Date Functions
746 @cindex functions, time & date
751 For compatibility, @pspp{} considers dates before 15 Oct 1582 invalid.
752 Most time and date functions will not accept earlier dates.
755 * Time and Date Concepts:: How times & dates are defined and represented
756 * Time Construction:: TIME.@{DAYS HMS@}
757 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
758 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
759 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
760 QUARTER SECOND TDAY TIME WEEK
762 * Time and Date Arithmetic:: DATEDIFF DATESUM
765 @node Time and Date Concepts
766 @subsubsection How times & dates are defined and represented
768 @cindex time, concepts
769 @cindex time, intervals
770 Times and dates are handled by @pspp{} as single numbers. A
771 @dfn{time} is an interval. @pspp{} measures times in seconds.
772 Thus, the following intervals correspond with the numeric values given:
777 1 day, 3 hours, 10 seconds 97,210
781 @cindex dates, concepts
782 @cindex time, instants of
783 A @dfn{date}, on the other hand, is a particular instant in the past
784 or the future. @pspp{} represents a date as a number of seconds since
785 midnight preceding 14 Oct 1582. Because midnight preceding the dates
786 given below correspond with the numeric @pspp{} dates given:
790 4 Jul 1776 6,113,318,400
791 1 Jan 1900 10,010,390,400
792 1 Oct 1978 12,495,427,200
793 24 Aug 1995 13,028,601,600
796 @node Time Construction
797 @subsubsection Functions that Produce Times
798 @cindex times, constructing
799 @cindex constructing times
801 These functions take numeric arguments and return numeric values that
805 @cindex time, in days
806 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
807 Returns a time corresponding to @var{ndays} days.
810 @cindex hours-minutes-seconds
811 @cindex time, in hours-minutes-seconds
812 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
813 Returns a time corresponding to @var{nhours} hours, @var{nmins}
814 minutes, and @var{nsecs} seconds. The arguments may not have mixed
815 signs: if any of them are positive, then none may be negative, and
819 @node Time Extraction
820 @subsubsection Functions that Examine Times
821 @cindex extraction, of time
822 @cindex time examination
823 @cindex examination, of times
824 @cindex time, lengths of
826 These functions take numeric arguments in @pspp{} time format and
827 give numeric results.
830 @cindex time, in days
831 @deftypefn {Function} {} CTIME.DAYS (@var{time})
832 Results in the number of days and fractional days in @var{time}.
836 @cindex time, in hours
837 @deftypefn {Function} {} CTIME.HOURS (@var{time})
838 Results in the number of hours and fractional hours in @var{time}.
842 @cindex time, in minutes
843 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
844 Results in the number of minutes and fractional minutes in @var{time}.
848 @cindex time, in seconds
849 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
850 Results in the number of seconds and fractional seconds in @var{time}.
851 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
852 equivalent to @code{@var{x}}.)
855 @node Date Construction
856 @subsubsection Functions that Produce Dates
857 @cindex dates, constructing
858 @cindex constructing dates
860 @cindex arguments, of date construction functions
861 These functions take numeric arguments and give numeric results that
862 represent dates. Arguments taken by these functions are:
866 Refers to a day of the month between 1 and 31. Day 0 is also accepted
867 and refers to the final day of the previous month. Days 29, 30, and
868 31 are accepted even in months that have fewer days and refer to a day
869 near the beginning of the following month.
872 Refers to a month of the year between 1 and 12. Months 0 and 13 are
873 also accepted and refer to the last month of the preceding year and
874 the first month of the following year, respectively.
877 Refers to a quarter of the year between 1 and 4. The quarters of the
878 year begin on the first day of months 1, 4, 7, and 10.
881 Refers to a week of the year between 1 and 53.
884 Refers to a day of the year between 1 and 366.
887 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
888 according to the epoch set on SET EPOCH, by default beginning 69 years
889 before the current date (@pxref{SET EPOCH}).
892 @cindex arguments, invalid
893 If these functions' arguments are out-of-range, they are correctly
894 normalized before conversion to date format. Non-integers are rounded
897 @cindex day-month-year
898 @cindex dates, day-month-year
899 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
900 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
901 Results in a date value corresponding to the midnight before day
902 @var{day} of month @var{month} of year @var{year}.
906 @cindex dates, month-year
907 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
908 Results in a date value corresponding to the midnight before the first
909 day of month @var{month} of year @var{year}.
913 @cindex dates, quarter-year
914 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
915 Results in a date value corresponding to the midnight before the first
916 day of quarter @var{quarter} of year @var{year}.
920 @cindex dates, week-year
921 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
922 Results in a date value corresponding to the midnight before the first
923 day of week @var{week} of year @var{year}.
927 @cindex dates, year-day
928 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
929 Results in a date value corresponding to the day
930 @var{yday} of year @var{year}.
933 @node Date Extraction
934 @subsubsection Functions that Examine Dates
935 @cindex extraction, of dates
936 @cindex date examination
938 @cindex arguments, of date extraction functions
939 These functions take numeric arguments in @pspp{} date or time
940 format and give numeric results. These names are used for arguments:
944 A numeric value in @pspp{} date format.
947 A numeric value in @pspp{} time format.
950 A numeric value in @pspp{} time or date format.
954 @cindex dates, in days
955 @cindex time, in days
956 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
957 For a time, results in the time corresponding to the number of whole
958 days @var{date-or-time} includes. For a date, results in the date
959 corresponding to the latest midnight at or before @var{date-or-time};
960 that is, gives the date that @var{date-or-time} is in.
964 @cindex dates, in hours
965 @cindex time, in hours
966 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
967 For a time, results in the number of whole hours beyond the number of
968 whole days represented by @var{date-or-time}. For a date, results in
969 the hour (as an integer between 0 and 23) corresponding to
973 @cindex day of the year
974 @cindex dates, day of the year
975 @deftypefn {Function} {} XDATE.JDAY (@var{date})
976 Results in the day of the year (as an integer between 1 and 366)
977 corresponding to @var{date}.
980 @cindex day of the month
981 @cindex dates, day of the month
982 @deftypefn {Function} {} XDATE.MDAY (@var{date})
983 Results in the day of the month (as an integer between 1 and 31)
984 corresponding to @var{date}.
988 @cindex dates, in minutes
989 @cindex time, in minutes
990 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
991 Results in the number of minutes (as an integer between 0 and 59) after
992 the last hour in @var{time-or-date}.
996 @cindex dates, in months
997 @deftypefn {Function} {} XDATE.MONTH (@var{date})
998 Results in the month of the year (as an integer between 1 and 12)
999 corresponding to @var{date}.
1003 @cindex dates, in quarters
1004 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
1005 Results in the quarter of the year (as an integer between 1 and 4)
1006 corresponding to @var{date}.
1010 @cindex dates, in seconds
1011 @cindex time, in seconds
1012 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
1013 Results in the number of whole seconds after the last whole minute (as
1014 an integer between 0 and 59) in @var{time-or-date}.
1018 @cindex times, in days
1019 @deftypefn {Function} {} XDATE.TDAY (@var{date})
1020 Results in the number of whole days from 14 Oct 1582 to @var{date}.
1024 @cindex dates, time of day
1025 @deftypefn {Function} {} XDATE.TIME (@var{date})
1026 Results in the time of day at the instant corresponding to @var{date},
1027 as a time value. This is the number of seconds since
1028 midnight on the day corresponding to @var{date}.
1032 @cindex dates, in weeks
1033 @deftypefn {Function} {} XDATE.WEEK (@var{date})
1034 Results in the week of the year (as an integer between 1 and 53)
1035 corresponding to @var{date}.
1038 @cindex day of the week
1040 @cindex dates, day of the week
1041 @cindex dates, in weekdays
1042 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
1043 Results in the day of week (as an integer between 1 and 7) corresponding
1044 to @var{date}, where 1 represents Sunday.
1048 @cindex dates, in years
1049 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1050 Returns the year (as an integer 1582 or greater) corresponding to
1054 @node Time and Date Arithmetic
1055 @subsubsection Time and Date Arithmetic
1057 @cindex time, mathematical properties of
1058 @cindex mathematics, applied to times & dates
1059 @cindex dates, mathematical properties of
1061 Ordinary arithmetic operations on dates and times often produce
1062 sensible results. Adding a time to, or subtracting one from, a date
1063 produces a new date that much earlier or later. The difference of two
1064 dates yields the time between those dates. Adding two times produces
1065 the combined time. Multiplying a time by a scalar produces a time
1066 that many times longer. Since times and dates are just numbers, the
1067 ordinary addition and subtraction operators are employed for these
1070 Adding two dates does not produce a useful result.
1072 Dates and times may have very large values. Thus,
1073 it is not a good idea to take powers of these values; also, the
1074 accuracy of some procedures may be affected. If necessary, convert
1075 times or dates in seconds to some other unit, like days or years,
1076 before performing analysis.
1078 @pspp{} supplies a few functions for date arithmetic:
1080 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
1081 Returns the span of time from @var{date1} to @var{date2} in terms of
1082 @var{unit}, which must be a quoted string, one of @samp{years},
1083 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1084 @samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an
1085 integer, truncated toward zero.
1087 One year is considered to span from a given date to the same month,
1088 day, and time of day the next year. Thus, from Jan.@tie{}1 of one
1089 year to Jan.@tie{}1 the next year is considered to be a full year, but
1090 Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not.
1091 Similarly, one month spans from a given day of the month to the same
1092 day of the following month. Thus, there is never a full month from
1093 Jan.@tie{}31 of a given year to any day in the following February.
1096 @deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}])
1097 Returns @var{date} advanced by the given @var{quantity} of the
1098 specified @var{unit}, which must be one of the strings @samp{years},
1099 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1100 @samp{hours}, @samp{minutes}, and @samp{seconds}.
1102 When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months},
1103 only the integer part of @var{quantity} is considered. Adding one of
1104 these units can cause the day of the month to exceed the number of
1105 days in the month. In this case, the @var{method} comes into
1106 play: if it is omitted or specified as @samp{closest} (as a quoted
1107 string), then the resulting day is the last day of the month;
1108 otherwise, if it is specified as @samp{rollover}, then the extra days
1109 roll over into the following month.
1111 When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours},
1112 @samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded
1113 to an integer and @var{method}, if specified, is ignored.
1116 @node Miscellaneous Functions
1117 @subsection Miscellaneous Functions
1118 @cindex functions, miscellaneous
1120 @cindex cross-case function
1121 @cindex function, cross-case
1122 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1125 @var{variable} must be a numeric or string variable name. @code{LAG}
1126 yields the value of that variable for the case @var{n} before the
1127 current one. Results in system-missing (for numeric variables) or
1128 blanks (for string variables) for the first @var{n} cases.
1130 @code{LAG} obtains values from the cases that become the new active
1132 after a procedure executes. Thus, @code{LAG} will not return values
1133 from cases dropped by transformations such as @cmd{SELECT IF}, and
1134 transformations like @cmd{COMPUTE} that modify data will change the
1135 values returned by @code{LAG}. These are both the case whether these
1136 transformations precede or follow the use of @code{LAG}.
1138 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1139 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1140 used after @cmd{TEMPORARY}.
1142 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1143 be a small positive constant integer. There is no explicit limit, but
1144 use of a large value will increase memory consumption.
1147 @cindex date, Julian
1149 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1150 @var{year} is a year, either between 0 and 99 or at least 1582.
1151 Unlike other @pspp{} date functions, years between 0 and 99 always
1152 correspond to 1900 through 1999. @var{month} is a month between 1 and
1153 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1154 the last day of the previous month, and a @var{month} of 13 refers to
1155 the first month of the next year. @var{year} must be in range.
1156 @var{year}, @var{month}, and @var{day} must all be integers.
1158 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1159 the date specified, plus one. The date passed to @code{YRMODA} must be
1160 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1164 @deftypefn {Function} VALUELABEL (@var{variable})
1165 Returns a string matching the label associated with the current value
1166 of @var{variable}. If the current value of @var{variable} has no
1167 associated label, then this function returns the empty string.
1168 @var{variable} may be a numeric or string variable.
1171 @node Statistical Distribution Functions
1172 @subsection Statistical Distribution Functions
1174 @pspp{} can calculate several functions of standard statistical
1175 distributions. These functions are named systematically based on the
1176 function and the distribution. The table below describes the
1177 statistical distribution functions in general:
1180 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1181 Probability density function for @var{dist}. The domain of @var{x}
1182 depends on @var{dist}. For continuous distributions, the result is
1183 the density of the probability function at @var{x}, and the range is
1184 nonnegative real numbers. For discrete distributions, the result is
1185 the probability of @var{x}.
1187 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1188 Cumulative distribution function for @var{dist}, that is, the
1189 probability that a random variate drawn from the distribution is less
1190 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1193 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1194 Tail probability function for @var{dist}, that is, the probability
1195 that a random variate drawn from the distribution is greater than
1196 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1197 probability. Only a few distributions include an @func{SIG} function.
1199 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1200 Inverse distribution function for @var{dist}, the value of @var{x} for
1201 which the CDF would yield @var{p}. The value of @var{p} is a
1202 probability. The range depends on @var{dist} and is identical to the
1203 domain for the corresponding CDF.
1205 @item RV.@var{dist} ([@var{param}@dots{}])
1206 Random variate function for @var{dist}. The range depends on the
1209 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1210 Noncentral probability density function. The result is the density of
1211 the given noncentral distribution at @var{x}. The domain of @var{x}
1212 depends on @var{dist}. The range is nonnegative real numbers. Only a
1213 few distributions include an @func{NPDF} function.
1215 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1216 Noncentral cumulative distribution function for @var{dist}, that is,
1217 the probability that a random variate drawn from the given noncentral
1218 distribution is less than @var{x}. The domain of @var{x} depends
1219 @var{dist}. The result is a probability. Only a few distributions
1220 include an NCDF function.
1223 The individual distributions are described individually below.
1226 * Continuous Distributions::
1227 * Discrete Distributions::
1230 @node Continuous Distributions
1231 @subsubsection Continuous Distributions
1233 The following continuous distributions are available:
1235 @deftypefn {Function} {} PDF.BETA (@var{x})
1236 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1237 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1238 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1239 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1240 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1241 Beta distribution with shape parameters @var{a} and @var{b}. The
1242 noncentral distribution takes an additional parameter @var{lambda}.
1243 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1244 <= 1, 0 <= @var{p} <= 1.
1247 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1248 @deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
1249 Bivariate normal distribution of two standard normal variables with
1250 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1251 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1254 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1255 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1256 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1257 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1258 Cauchy distribution with location parameter @var{a} and scale
1259 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1262 @c @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1263 @deftypefn {Function} {} CDF.CHISQ (@var{x}, @var{df})
1264 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1265 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1266 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1267 @c @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1268 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1269 Chi-squared distribution with @var{df} degrees of freedom. The
1270 noncentral distribution takes an additional parameter @var{lambda}.
1271 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1275 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1276 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1277 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1278 @deftypefnx {Function} {} RV.EXP (@var{a})
1279 Exponential distribution with scale parameter @var{a}. The inverse of
1280 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1281 @var{x} >= 0, 0 <= @var{p} < 1.
1284 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1285 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1286 Exponential power distribution with positive scale parameter @var{a}
1287 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1288 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1292 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1293 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1294 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1295 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1296 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1297 @c @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1298 @c @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1299 F-distribution of two chi-squared deviates with @var{df1} and
1300 @var{df2} degrees of freedom. The noncentral distribution takes an
1301 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1302 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1305 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1306 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1307 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1308 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1309 Gamma distribution with shape parameter @var{a} and scale parameter
1310 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1314 @c @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1315 @c @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1316 @c @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1317 @c @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1318 @c Half-normal distribution with location parameter @var{a} and shape
1319 @c parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1322 @c @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1323 @c @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1324 @c @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1325 @c @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1326 @c Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1327 @c Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1330 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1331 @deftypefnx {Function} {} RV.LANDAU ()
1332 Landau distribution.
1335 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1336 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1337 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1338 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1339 Laplace distribution with location parameter @var{a} and scale
1340 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1343 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1344 Levy symmetric alpha-stable distribution with scale @var{c} and
1345 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1348 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1349 Levy skew alpha-stable distribution with scale @var{c}, exponent
1350 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1351 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1354 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1355 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1356 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1357 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1358 Logistic distribution with location parameter @var{a} and scale
1359 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1362 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1363 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1364 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1365 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1366 Lognormal distribution with parameters @var{a} and @var{b}.
1367 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1370 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1371 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1372 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1373 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1374 Normal distribution with mean @var{mu} and standard deviation
1375 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1376 additional functions are available as shorthand:
1378 @deftypefn {Function} {} CDFNORM (@var{x})
1379 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1382 @deftypefn {Function} {} PROBIT (@var{p})
1383 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1386 @deftypefn {Function} {} NORMAL (@var{sigma})
1387 Equivalent to RV.NORMAL(0, @var{sigma}).
1391 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1392 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1393 Normal tail distribution with lower limit @var{a} and standard
1394 deviation @var{sigma}. This distribution is a @pspp{} extension.
1395 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1398 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1399 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1400 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1401 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1402 Pareto distribution with threshold parameter @var{a} and shape
1403 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1404 @var{a}, 0 <= @var{p} < 1.
1407 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1408 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1409 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1410 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1411 Rayleigh distribution with scale parameter @var{sigma}. This
1412 distribution is a @pspp{} extension. Constraints: @var{sigma} > 0,
1416 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1417 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1418 Rayleigh tail distribution with lower limit @var{a} and scale
1419 parameter @var{sigma}. This distribution is a @pspp{} extension.
1420 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1423 @c @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1424 @c @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1425 @c Studentized maximum modulus distribution with parameters @var{a} and
1426 @c @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1430 @c @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1431 @c @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1432 @c Studentized range distribution with parameters @var{a} and @var{b}.
1433 @c Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1437 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1438 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1439 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1440 @deftypefnx {Function} {} RV.T (@var{df})
1441 @c @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1442 @c @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1443 T-distribution with @var{df} degrees of freedom. The noncentral
1444 distribution takes an additional parameter @var{lambda}. Constraints:
1445 @var{df} > 0, 0 < @var{p} < 1.
1448 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1449 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1450 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1451 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1452 distribution is a @pspp{} extension. Constraints: 0 < @var{p} < 1.
1455 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1456 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1457 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1458 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1459 distribution is a @pspp{} extension. Constraints: @var{x} > 0, 0 <
1463 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1464 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1465 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1466 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1467 Uniform distribution with parameters @var{a} and @var{b}.
1468 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1469 additional function is available as shorthand:
1471 @deftypefn {Function} {} UNIFORM (@var{b})
1472 Equivalent to RV.UNIFORM(0, @var{b}).
1476 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1477 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1478 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1479 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1480 Weibull distribution with parameters @var{a} and @var{b}.
1481 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1484 @node Discrete Distributions
1485 @subsubsection Discrete Distributions
1487 The following discrete distributions are available:
1489 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1490 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1491 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1492 Bernoulli distribution with probability of success @var{p}.
1493 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1496 @deftypefn {Function} {} PDF.BINOM (@var{x}, @var{n}, @var{p})
1497 @deftypefnx {Function} {} CDF.BINOM (@var{x}, @var{n}, @var{p})
1498 @deftypefnx {Function} {} RV.BINOM (@var{n}, @var{p})
1499 Binomial distribution with @var{n} trials and probability of success
1500 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1504 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1505 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1506 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1507 Geometric distribution with probability of success @var{p}.
1508 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1511 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1512 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1513 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1514 Hypergeometric distribution when @var{b} objects out of @var{a} are
1515 drawn and @var{c} of the available objects are distinctive.
1516 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1517 @var{c} <= @var{a}, integer @var{x} >= 0.
1520 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1521 @deftypefnx {Function} {} RV.LOG (@var{p})
1522 Logarithmic distribution with probability parameter @var{p}.
1523 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1526 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1527 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1528 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1529 Negative binomial distribution with number of successes parameter
1530 @var{n} and probability of success parameter @var{p}. Constraints:
1531 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1534 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1535 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1536 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1537 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1538 integer @var{x} >= 0.
1541 @node Order of Operations
1542 @section Operator Precedence
1543 @cindex operator precedence
1544 @cindex precedence, operator
1545 @cindex order of operations
1546 @cindex operations, order of
1548 The following table describes operator precedence. Smaller-numbered
1549 levels in the table have higher precedence. Within a level,
1550 operations are always performed from left to right. The first
1551 occurrence of @samp{-} represents unary negation, the second binary
1566 @code{EQ GE GT LE LT NE}