1 @c Use @func when refering to a function.
2 @c Use @deftypefn for their definitions
8 @chapter Mathematical Expressions
9 @cindex expressions, mathematical
10 @cindex mathematical expressions
12 Expressions share a common syntax each place they appear in @pspp{}
13 commands. Expressions are made up of @dfn{operands}, which can be
14 numbers, strings, or variable names, separated by @dfn{operators}.
15 There are five types of operators: grouping, arithmetic, logical,
16 relational, and functions.
18 Every operator takes one or more operands as input and yields exactly
19 one result as output. Depending on the operator, operands accept
20 strings or numbers as operands. With few exceptions, operands may be
21 full-fledged expressions in themselves.
24 * Boolean Values:: Boolean values
25 * Missing Values in Expressions:: Using missing values in expressions
26 * Grouping Operators:: parentheses
27 * Arithmetic Operators:: add sub mul div pow
28 * Logical Operators:: AND NOT OR
29 * Relational Operators:: EQ GE GT LE LT NE
30 * Functions:: More-sophisticated operators
31 * Order of Operations:: Operator precedence
35 @section Boolean Values
37 @cindex values, Boolean
39 Some @pspp{} operators and expressions work with Boolean values, which
40 represent true/false conditions. Booleans have only three possible
41 values: 0 (false), 1 (true), and system-missing (unknown).
42 System-missing is neither true nor false and indicates that the true
45 Boolean-typed operands or function arguments must take on one of these
46 three values. Other values are considered false, but provoke a warning
47 when the expression is evaluated.
49 Strings and Booleans are not compatible, and neither may be used in
52 @node Missing Values in Expressions
53 @section Missing Values in Expressions
55 Most numeric operators yield system-missing when given any
56 system-missing operand. A string operator given any system-missing
57 operand typically results in the empty string. Exceptions are listed
58 under particular operator descriptions.
60 String user-missing values are not treated specially in expressions.
62 User-missing values for numeric variables are always transformed into
63 the system-missing value, except inside the arguments to the
64 @code{VALUE} and @code{SYSMIS} functions.
66 The missing-value functions can be used to precisely control how missing
67 values are treated in expressions. @xref{Missing Value Functions}, for
70 @node Grouping Operators
71 @section Grouping Operators
74 @cindex grouping operators
75 @cindex operators, grouping
77 Parentheses (@samp{()}) are the grouping operators. Surround an
78 expression with parentheses to force early evaluation.
80 Parentheses also surround the arguments to functions, but in that
81 situation they act as punctuators, not as operators.
83 @node Arithmetic Operators
84 @section Arithmetic Operators
85 @cindex operators, arithmetic
86 @cindex arithmetic operators
88 The arithmetic operators take numeric operands and produce numeric
94 @item @var{a} + @var{b}
95 Yields the sum of @var{a} and @var{b}.
99 @item @var{a} - @var{b}
100 Subtracts @var{b} from @var{a} and yields the difference.
103 @cindex multiplication
104 @item @var{a} * @var{b}
105 Yields the product of @var{a} and @var{b}. If either @var{a} or
106 @var{b} is 0, then the result is 0, even if the other operand is
111 @item @var{a} / @var{b}
112 Divides @var{a} by @var{b} and yields the quotient. If @var{a} is 0,
113 then the result is 0, even if @var{b} is missing. If @var{b} is zero,
114 the result is system-missing.
117 @cindex exponentiation
118 @item @var{a} ** @var{b}
119 Yields the result of raising @var{a} to the power @var{b}. If
120 @var{a} is negative and @var{b} is not an integer, the result is
121 system-missing. The result of @code{0**0} is system-missing as well.
126 Reverses the sign of @var{a}.
129 @node Logical Operators
130 @section Logical Operators
131 @cindex logical operators
132 @cindex operators, logical
137 @cindex values, system-missing
138 @cindex system-missing
139 The logical operators take logical operands and produce logical
140 results, meaning ``true or false.'' Logical operators are
141 not true Boolean operators because they may also result in a
142 system-missing value. @xref{Boolean Values}, for more information.
147 @cindex intersection, logical
148 @cindex logical intersection
149 @item @var{a} AND @var{b}
150 @itemx @var{a} & @var{b}
151 True if both @var{a} and @var{b} are true, false otherwise. If one
152 operand is false, the result is false even if the other is missing. If
153 both operands are missing, the result is missing.
157 @cindex union, logical
158 @cindex logical union
159 @item @var{a} OR @var{b}
160 @itemx @var{a} | @var{b}
161 True if at least one of @var{a} and @var{b} is true. If one operand is
162 true, the result is true even if the other operand is missing. If both
163 operands are missing, the result is missing.
167 @cindex inversion, logical
168 @cindex logical inversion
171 True if @var{a} is false. If the operand is missing, then the result
175 @node Relational Operators
176 @section Relational Operators
178 The relational operators take numeric or string operands and produce Boolean
181 Strings cannot be compared to numbers. When strings of different
182 lengths are compared, the shorter string is right-padded with spaces
183 to match the length of the longer string.
185 The results of string comparisons, other than tests for equality or
186 inequality, depend on the character set in use. String comparisons
190 @cindex equality, testing
191 @cindex testing for equality
194 @item @var{a} EQ @var{b}
195 @itemx @var{a} = @var{b}
196 True if @var{a} is equal to @var{b}.
198 @cindex less than or equal to
201 @item @var{a} LE @var{b}
202 @itemx @var{a} <= @var{b}
203 True if @var{a} is less than or equal to @var{b}.
208 @item @var{a} LT @var{b}
209 @itemx @var{a} < @var{b}
210 True if @var{a} is less than @var{b}.
212 @cindex greater than or equal to
215 @item @var{a} GE @var{b}
216 @itemx @var{a} >= @var{b}
217 True if @var{a} is greater than or equal to @var{b}.
222 @item @var{a} GT @var{b}
223 @itemx @var{a} > @var{b}
224 True if @var{a} is greater than @var{b}.
226 @cindex inequality, testing
227 @cindex testing for inequality
231 @item @var{a} NE @var{b}
232 @itemx @var{a} ~= @var{b}
233 @itemx @var{a} <> @var{b}
234 True if @var{a} is not equal to @var{b}.
246 @cindex names, of functions
247 @pspp{} functions provide mathematical abilities above and beyond
248 those possible using simple operators. Functions have a common
249 syntax: each is composed of a function name followed by a left
250 parenthesis, one or more arguments, and a right parenthesis.
252 Function names are not reserved. Their names are specially treated
253 only when followed by a left parenthesis, so that @samp{EXP(10)}
254 refers to the constant value @math{e} raised to the 10th power, but
255 @samp{EXP} by itself refers to the value of a variable called @code{EXP}.
257 The sections below describe each function in detail.
260 * Mathematics:: EXP LG10 LN LNGAMMA SQRT
261 * Miscellaneous Mathematics:: ABS MOD MOD10 RND TRUNC
262 * Trigonometry:: ACOS ARCOS ARSIN ARTAN ASIN ATAN COS SIN TAN
263 * Missing Value Functions:: MISSING NMISS NVALID SYSMIS VALUE
264 * Set Membership:: ANY RANGE
265 * Statistical Functions:: CFVAR MAX MEAN MEDIAN MIN SD SUM VARIANCE
266 * String Functions:: CONCAT INDEX LENGTH LOWER LPAD LTRIM NUMBER
267 REPLACE RINDEX RPAD RTRIM STRING STRUNC SUBSTR
269 * Time and Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
271 * Miscellaneous Functions:: LAG YRMODA VALUELABEL
272 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
276 @subsection Mathematical Functions
277 @cindex mathematics, advanced
279 Advanced mathematical functions take numeric arguments and produce
282 @deftypefn {Function} {} EXP (@var{exponent})
283 Returns @math{e} (approximately 2.71828) raised to power @var{exponent}.
287 @deftypefn {Function} {} LG10 (@var{number})
288 Takes the base-10 logarithm of @var{number}. If @var{number} is
289 not positive, the result is system-missing.
292 @deftypefn {Function} {} LN (@var{number})
293 Takes the base-@math{e} logarithm of @var{number}. If @var{number} is
294 not positive, the result is system-missing.
297 @deftypefn {Function} {} LNGAMMA (@var{number})
298 Yields the base-@math{e} logarithm of the complete gamma of @var{number}.
299 If @var{number} is a negative integer, the result is system-missing.
303 @deftypefn {Function} {} SQRT (@var{number})
304 Takes the square root of @var{number}. If @var{number} is negative,
305 the result is system-missing.
308 @node Miscellaneous Mathematics
309 @subsection Miscellaneous Mathematical Functions
310 @cindex mathematics, miscellaneous
312 Miscellaneous mathematical functions take numeric arguments and produce
315 @cindex absolute value
316 @deftypefn {Function} {} ABS (@var{number})
317 Results in the absolute value of @var{number}.
321 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
322 Returns the remainder (modulus) of @var{numerator} divided by
323 @var{denominator}. If @var{numerator} is 0, then the result is 0,
324 even if @var{denominator} is missing. If @var{denominator} is 0, the
325 result is system-missing.
328 @cindex modulus, by 10
329 @deftypefn {Function} {} MOD10 (@var{number})
330 Returns the remainder when @var{number} is divided by 10. If
331 @var{number} is negative, MOD10(@var{number}) is negative or zero.
335 @deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
336 Rounds @var{number} and rounds it to a multiple of @var{mult} (by
337 default 1). Halves are rounded away from zero, as are values that
338 fall short of halves by less than @var{fuzzbits} of errors in the
339 least-significant bits of @var{number}. If @var{fuzzbits} is not
340 specified then the default is taken from SET FUZZBITS (@pxref{SET
341 FUZZBITS}), which is 6 unless overridden.
345 @deftypefn {Function} {} TRUNC (@var{number})
346 Discards the fractional part of @var{number}; that is, rounds
347 @var{number} towards zero.
351 @subsection Trigonometric Functions
354 Trigonometric functions take numeric arguments and produce numeric
358 @cindex inverse cosine
359 @deftypefn {Function} {} ARCOS (@var{number})
360 @deftypefnx {Function} {} ACOS (@var{number})
361 Takes the arccosine, in radians, of @var{number}. Results in
362 system-missing if @var{number} is not between -1 and 1 inclusive.
363 This function is a @pspp{} extension.
368 @deftypefn {Function} {} ARSIN (@var{number})
369 @deftypefnx {Function} {} ASIN (@var{number})
370 Takes the arcsine, in radians, of @var{number}. Results in
371 system-missing if @var{number} is not between -1 and 1 inclusive.
375 @cindex inverse tangent
376 @deftypefn {Function} {} ARTAN (@var{number})
377 @deftypefnx {Function} {} ATAN (@var{number})
378 Takes the arctangent, in radians, of @var{number}.
382 @deftypefn {Function} {} COS (@var{angle})
383 Takes the cosine of @var{angle} which should be in radians.
387 @deftypefn {Function} {} SIN (@var{angle})
388 Takes the sine of @var{angle} which should be in radians.
392 @deftypefn {Function} {} TAN (@var{angle})
393 Takes the tangent of @var{angle} which should be in radians.
394 Results in system-missing at values
395 of @var{angle} that are too close to odd multiples of @math{\pi/2}.
399 @node Missing Value Functions
400 @subsection Missing-Value Functions
401 @cindex missing values
402 @cindex values, missing
403 @cindex functions, missing-value
405 Missing-value functions take various numeric arguments and yield
406 various types of results. Except where otherwise stated below, the
407 normal rules of evaluation apply within expression arguments to these
408 functions. In particular, user-missing values for numeric variables
409 are converted to system-missing values.
411 @deftypefn {Function} {} MISSING (@var{expr})
412 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
415 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
416 Each argument must be a numeric expression. Returns the number of
417 system-missing values in the list, which may include variable ranges
418 using the @code{@var{var1} TO @var{var2}} syntax.
421 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
422 Each argument must be a numeric expression. Returns the number of
423 values in the list that are not system-missing. The list may include
424 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
427 @deftypefn {Function} {} SYSMIS (@var{expr})
428 When @var{expr} is simply the name of a numeric variable, returns 1 if
429 the variable has the system-missing value, 0 if it is user-missing or
430 not missing. If given @var{expr} takes another form, results in 1 if
431 the value is system-missing, 0 otherwise.
434 @deftypefn {Function} {} VALUE (@var{variable})
435 Prevents the user-missing values of @var{variable} from being
436 transformed into system-missing values, and always results in the
437 actual value of @var{variable}, whether it is valid, user-missing, or
442 @subsection Set-Membership Functions
443 @cindex set membership
444 @cindex membership, of set
446 Set membership functions determine whether a value is a member of a set.
447 They take a set of numeric arguments or a set of string arguments, and
448 produce Boolean results.
450 String comparisons are performed according to the rules given in
451 @ref{Relational Operators}.
453 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
454 Results in true if @var{value} is equal to any of the @var{set}
455 values. Otherwise, results in false. If @var{value} is
456 system-missing, returns system-missing. System-missing values in
457 @var{set} do not cause @func{ANY} to return system-missing.
460 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
461 Results in true if @var{value} is in any of the intervals bounded by
462 @var{low} and @var{high} inclusive. Otherwise, results in false.
463 Each @var{low} must be less than or equal to its corresponding
464 @var{high} value. @var{low} and @var{high} must be given in pairs.
465 If @var{value} is system-missing, returns system-missing.
466 System-missing values in @var{set} do not cause @func{RANGE} to return
470 @node Statistical Functions
471 @subsection Statistical Functions
472 @cindex functions, statistical
475 Statistical functions compute descriptive statistics on a list of
476 values. Some statistics can be computed on numeric or string values;
477 other can only be computed on numeric values. Their results have the
478 same type as their arguments. The current case's weighting factor
479 (@pxref{WEIGHT}) has no effect on statistical functions.
481 These functions' argument lists may include entire ranges of variables
482 using the @code{@var{var1} TO @var{var2}} syntax.
484 @cindex arguments, minimum valid
485 @cindex minimum valid number of arguments
486 Unlike most functions, statistical functions can return non-missing
487 values even when some of their arguments are missing. Most
488 statistical functions, by default, require only 1 non-missing value to
489 have a non-missing return, but @func{CFVAR}, @func{SD}, and @func {VARIANCE} require 2.
490 These defaults can be increased (but not decreased) by appending a dot
491 and the minimum number of valid arguments to the function name. For
492 example, @subcmd{MEAN.3(X, Y, Z)} would only return non-missing if all
493 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
495 @cindex coefficient of variation
496 @cindex variation, coefficient of
497 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
498 Results in the coefficient of variation of the values of @var{number}.
499 (The coefficient of variation is the standard deviation divided by the
504 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
505 Results in the value of the greatest @var{value}. The @var{value}s may
506 be numeric or string.
510 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
511 Results in the mean of the values of @var{number}.
515 @deftypefn {Function} {} MEDIAN (@var{number}, @var{number}[, @dots{}])
516 Results in the median of the values of @var{number}. Given an even
517 number of nonmissing arguments, yields the mean of the two middle
522 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
523 Results in the value of the least @var{value}. The @var{value}s may
524 be numeric or string.
527 @cindex standard deviation
528 @cindex deviation, standard
529 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
530 Results in the standard deviation of the values of @var{number}.
534 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
535 Results in the sum of the values of @var{number}.
539 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
540 Results in the variance of the values of @var{number}.
543 @node String Functions
544 @subsection String Functions
545 @cindex functions, string
546 @cindex string functions
548 String functions take various arguments and return various results.
550 @cindex concatenation
551 @cindex strings, concatenation of
552 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
553 Returns a string consisting of each @var{string} in sequence.
554 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
555 The resultant string is truncated to a maximum of 255 characters.
558 @cindex searching strings
559 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
560 Returns a positive integer indicating the position of the first
561 occurrence of @var{needle} in @var{haystack}. Returns 0 if @var{haystack}
562 does not contain @var{needle}. Returns system-missing if @var{needle}
566 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
567 Divides @var{needles} into one or more needles, each with length
569 Searches @var{haystack} for the first occurrence of each needle, and
570 returns the smallest value. Returns 0 if @var{haystack} does not
571 contain any part in @var{needle}. It is an error if @var{needle_len}
572 does not evenly divide the length of @var{needles}. Returns
573 system-missing if @var{needles} is an empty string.
576 @cindex strings, finding length of
577 @deftypefn {Function} {} LENGTH (@var{string})
578 Returns the number of characters in @var{string}.
581 @cindex strings, case of
582 @deftypefn {Function} {} LOWER (@var{string})
583 Returns a string identical to @var{string} except that all uppercase
584 letters are changed to lowercase letters. The definitions of
585 ``uppercase'' and ``lowercase'' are system-dependent.
588 @cindex strings, padding
589 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
590 If @var{string} is at least @var{length} characters in length, returns
591 @var{string} unchanged. Otherwise, returns @var{string} padded with
592 spaces on the left side to length @var{length}. Returns an empty string
593 if @var{length} is system-missing, negative, or greater than 255.
596 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
597 If @var{string} is at least @var{length} characters in length, returns
598 @var{string} unchanged. Otherwise, returns @var{string} padded with
599 @var{padding} on the left side to length @var{length}. Returns an empty
600 string if @var{length} is system-missing, negative, or greater than 255, or
601 if @var{padding} does not contain exactly one character.
604 @cindex strings, trimming
605 @cindex white space, trimming
606 @deftypefn {Function} {} LTRIM (@var{string})
607 Returns @var{string}, after removing leading spaces. Other white space,
608 such as tabs, carriage returns, line feeds, and vertical tabs, is not
612 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
613 Returns @var{string}, after removing leading @var{padding} characters.
614 If @var{padding} does not contain exactly one character, returns an
618 @cindex numbers, converting from strings
619 @cindex strings, converting to numbers
620 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
621 Returns the number produced when @var{string} is interpreted according
622 to format specifier @var{format}. If the format width @var{w} is less
623 than the length of @var{string}, then only the first @var{w}
624 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
625 and @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
626 greater than @var{string}'s length, then it is treated as if it were
627 right-padded with spaces. If @var{string} is not in the correct
628 format for @var{format}, system-missing is returned.
631 @cindex strings, replacing substrings
632 @cindex replacing substrings
633 @deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
634 Returns string @var{haystack} with instances of @var{needle} replaced
635 by @var{replacement}. If nonnegative integer @var{n} is specified, it
636 limits the maximum number of replacements; otherwise, all instances of
637 @var{needle} are replaced.
640 @cindex strings, searching backwards
641 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle})
642 Returns a positive integer indicating the position of the last
643 occurrence of @var{needle} in @var{haystack}. Returns 0 if
644 @var{haystack} does not contain @var{needle}. Returns system-missing if
645 @var{needle} is an empty string.
648 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
649 Divides @var{needle} into parts, each with length @var{needle_len}.
650 Searches @var{haystack} for the last occurrence of each part, and
651 returns the largest value. Returns 0 if @var{haystack} does not contain
652 any part in @var{needle}. It is an error if @var{needle_len} does not
653 evenly divide the length of @var{needle}. Returns system-missing
654 if @var{needle} is an empty string or if needle_len is less than 1.
657 @cindex padding strings
658 @cindex strings, padding
659 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
660 If @var{string} is at least @var{length} characters in length, returns
661 @var{string} unchanged. Otherwise, returns @var{string} padded with
662 spaces on the right to length @var{length}. Returns an empty string if
663 @var{length} is system-missing, negative, or greater than 255.
666 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
667 If @var{string} is at least @var{length} characters in length, returns
668 @var{string} unchanged. Otherwise, returns @var{string} padded with
669 @var{padding} on the right to length @var{length}. Returns an empty
670 string if @var{length} is system-missing, negative, or greater than 255,
671 or if @var{padding} does not contain exactly one character.
674 @cindex strings, trimming
675 @cindex white space, trimming
676 @deftypefn {Function} {} RTRIM (@var{string})
677 Returns @var{string}, after removing trailing spaces. Other types of
678 white space are not removed.
681 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
682 Returns @var{string}, after removing trailing @var{padding} characters.
683 If @var{padding} does not contain exactly one character, returns an
687 @cindex strings, converting from numbers
688 @cindex numbers, converting to strings
689 @deftypefn {Function} {} STRING (@var{number}, @var{format})
690 Returns a string corresponding to @var{number} in the format given by
691 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
692 has the value @code{"123.6"}.
695 @cindex strings, trimming
696 @cindex strings, truncating
697 @cindex white space, trimming
698 @deftypefn {Function} {} STRUNC (@var{string}, @var{n})
699 Returns @var{string}, first trimming it to at most @var{n} bytes, then
700 removing trailing spaces. Returns an empty string if @var{n} is
705 @cindex strings, taking substrings of
706 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
707 Returns a string consisting of the value of @var{string} from position
708 @var{start} onward. Returns an empty string if @var{start} is system-missing,
709 less than 1, or greater than the length of @var{string}.
712 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
713 Returns a string consisting of the first @var{count} characters from
714 @var{string} beginning at position @var{start}. Returns an empty string
715 if @var{start} or @var{count} is system-missing, if @var{start} is less
716 than 1 or greater than the number of characters in @var{string}, or if
717 @var{count} is less than 1. Returns a string shorter than @var{count}
718 characters if @var{start} + @var{count} - 1 is greater than the number
719 of characters in @var{string}. Examples: @code{SUBSTR("abcdefg", 3, 2)}
720 has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
724 @cindex case conversion
725 @cindex strings, case of
726 @deftypefn {Function} {} UPCASE (@var{string})
727 Returns @var{string}, changing lowercase letters to uppercase letters.
731 @subsection Time & Date Functions
732 @cindex functions, time & date
737 For compatibility, @pspp{} considers dates before 15 Oct 1582 invalid.
738 Most time and date functions will not accept earlier dates.
741 * Time and Date Concepts:: How times & dates are defined and represented
742 * Time Construction:: TIME.@{DAYS HMS@}
743 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
744 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
745 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
746 QUARTER SECOND TDAY TIME WEEK
748 * Time and Date Arithmetic:: DATEDIFF DATESUM
751 @node Time and Date Concepts
752 @subsubsection How times & dates are defined and represented
754 @cindex time, concepts
755 @cindex time, intervals
756 Times and dates are handled by @pspp{} as single numbers. A
757 @dfn{time} is an interval. @pspp{} measures times in seconds.
758 Thus, the following intervals correspond with the numeric values given:
763 1 day, 3 hours, 10 seconds 97,210
767 @cindex dates, concepts
768 @cindex time, instants of
769 A @dfn{date}, on the other hand, is a particular instant in the past
770 or the future. @pspp{} represents a date as a number of seconds since
771 midnight preceding 14 Oct 1582. Because midnight preceding the dates
772 given below correspond with the numeric @pspp{} dates given:
776 4 Jul 1776 6,113,318,400
777 1 Jan 1900 10,010,390,400
778 1 Oct 1978 12,495,427,200
779 24 Aug 1995 13,028,601,600
782 @node Time Construction
783 @subsubsection Functions that Produce Times
784 @cindex times, constructing
785 @cindex constructing times
787 These functions take numeric arguments and return numeric values that
791 @cindex time, in days
792 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
793 Returns a time corresponding to @var{ndays} days.
796 @cindex hours-minutes-seconds
797 @cindex time, in hours-minutes-seconds
798 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
799 Returns a time corresponding to @var{nhours} hours, @var{nmins}
800 minutes, and @var{nsecs} seconds. The arguments may not have mixed
801 signs: if any of them are positive, then none may be negative, and
805 @node Time Extraction
806 @subsubsection Functions that Examine Times
807 @cindex extraction, of time
808 @cindex time examination
809 @cindex examination, of times
810 @cindex time, lengths of
812 These functions take numeric arguments in @pspp{} time format and
813 give numeric results.
816 @cindex time, in days
817 @deftypefn {Function} {} CTIME.DAYS (@var{time})
818 Results in the number of days and fractional days in @var{time}.
822 @cindex time, in hours
823 @deftypefn {Function} {} CTIME.HOURS (@var{time})
824 Results in the number of hours and fractional hours in @var{time}.
828 @cindex time, in minutes
829 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
830 Results in the number of minutes and fractional minutes in @var{time}.
834 @cindex time, in seconds
835 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
836 Results in the number of seconds and fractional seconds in @var{time}.
837 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
838 equivalent to @code{@var{x}}.)
841 @node Date Construction
842 @subsubsection Functions that Produce Dates
843 @cindex dates, constructing
844 @cindex constructing dates
846 @cindex arguments, of date construction functions
847 These functions take numeric arguments and give numeric results that
848 represent dates. Arguments taken by these functions are:
852 Refers to a day of the month between 1 and 31. Day 0 is also accepted
853 and refers to the final day of the previous month. Days 29, 30, and
854 31 are accepted even in months that have fewer days and refer to a day
855 near the beginning of the following month.
858 Refers to a month of the year between 1 and 12. Months 0 and 13 are
859 also accepted and refer to the last month of the preceding year and
860 the first month of the following year, respectively.
863 Refers to a quarter of the year between 1 and 4. The quarters of the
864 year begin on the first day of months 1, 4, 7, and 10.
867 Refers to a week of the year between 1 and 53.
870 Refers to a day of the year between 1 and 366.
873 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
874 according to the epoch set on SET EPOCH, by default beginning 69 years
875 before the current date (@pxref{SET EPOCH}).
878 @cindex arguments, invalid
879 If these functions' arguments are out-of-range, they are correctly
880 normalized before conversion to date format. Non-integers are rounded
883 @cindex day-month-year
884 @cindex dates, day-month-year
885 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
886 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
887 Results in a date value corresponding to the midnight before day
888 @var{day} of month @var{month} of year @var{year}.
892 @cindex dates, month-year
893 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
894 Results in a date value corresponding to the midnight before the first
895 day of month @var{month} of year @var{year}.
899 @cindex dates, quarter-year
900 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
901 Results in a date value corresponding to the midnight before the first
902 day of quarter @var{quarter} of year @var{year}.
906 @cindex dates, week-year
907 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
908 Results in a date value corresponding to the midnight before the first
909 day of week @var{week} of year @var{year}.
913 @cindex dates, year-day
914 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
915 Results in a date value corresponding to the day
916 @var{yday} of year @var{year}.
919 @node Date Extraction
920 @subsubsection Functions that Examine Dates
921 @cindex extraction, of dates
922 @cindex date examination
924 @cindex arguments, of date extraction functions
925 These functions take numeric arguments in @pspp{} date or time
926 format and give numeric results. These names are used for arguments:
930 A numeric value in @pspp{} date format.
933 A numeric value in @pspp{} time format.
936 A numeric value in @pspp{} time or date format.
940 @cindex dates, in days
941 @cindex time, in days
942 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
943 For a time, results in the time corresponding to the number of whole
944 days @var{date-or-time} includes. For a date, results in the date
945 corresponding to the latest midnight at or before @var{date-or-time};
946 that is, gives the date that @var{date-or-time} is in.
950 @cindex dates, in hours
951 @cindex time, in hours
952 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
953 For a time, results in the number of whole hours beyond the number of
954 whole days represented by @var{date-or-time}. For a date, results in
955 the hour (as an integer between 0 and 23) corresponding to
959 @cindex day of the year
960 @cindex dates, day of the year
961 @deftypefn {Function} {} XDATE.JDAY (@var{date})
962 Results in the day of the year (as an integer between 1 and 366)
963 corresponding to @var{date}.
966 @cindex day of the month
967 @cindex dates, day of the month
968 @deftypefn {Function} {} XDATE.MDAY (@var{date})
969 Results in the day of the month (as an integer between 1 and 31)
970 corresponding to @var{date}.
974 @cindex dates, in minutes
975 @cindex time, in minutes
976 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
977 Results in the number of minutes (as an integer between 0 and 59) after
978 the last hour in @var{time-or-date}.
982 @cindex dates, in months
983 @deftypefn {Function} {} XDATE.MONTH (@var{date})
984 Results in the month of the year (as an integer between 1 and 12)
985 corresponding to @var{date}.
989 @cindex dates, in quarters
990 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
991 Results in the quarter of the year (as an integer between 1 and 4)
992 corresponding to @var{date}.
996 @cindex dates, in seconds
997 @cindex time, in seconds
998 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
999 Results in the number of whole seconds after the last whole minute (as
1000 an integer between 0 and 59) in @var{time-or-date}.
1004 @cindex times, in days
1005 @deftypefn {Function} {} XDATE.TDAY (@var{date})
1006 Results in the number of whole days from 14 Oct 1582 to @var{date}.
1010 @cindex dates, time of day
1011 @deftypefn {Function} {} XDATE.TIME (@var{date})
1012 Results in the time of day at the instant corresponding to @var{date},
1013 as a time value. This is the number of seconds since
1014 midnight on the day corresponding to @var{date}.
1018 @cindex dates, in weeks
1019 @deftypefn {Function} {} XDATE.WEEK (@var{date})
1020 Results in the week of the year (as an integer between 1 and 53)
1021 corresponding to @var{date}.
1024 @cindex day of the week
1026 @cindex dates, day of the week
1027 @cindex dates, in weekdays
1028 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
1029 Results in the day of week (as an integer between 1 and 7) corresponding
1030 to @var{date}, where 1 represents Sunday.
1034 @cindex dates, in years
1035 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1036 Returns the year (as an integer 1582 or greater) corresponding to
1040 @node Time and Date Arithmetic
1041 @subsubsection Time and Date Arithmetic
1043 @cindex time, mathematical properties of
1044 @cindex mathematics, applied to times & dates
1045 @cindex dates, mathematical properties of
1047 Ordinary arithmetic operations on dates and times often produce
1048 sensible results. Adding a time to, or subtracting one from, a date
1049 produces a new date that much earlier or later. The difference of two
1050 dates yields the time between those dates. Adding two times produces
1051 the combined time. Multiplying a time by a scalar produces a time
1052 that many times longer. Since times and dates are just numbers, the
1053 ordinary addition and subtraction operators are employed for these
1056 Adding two dates does not produce a useful result.
1058 Dates and times may have very large values. Thus,
1059 it is not a good idea to take powers of these values; also, the
1060 accuracy of some procedures may be affected. If necessary, convert
1061 times or dates in seconds to some other unit, like days or years,
1062 before performing analysis.
1064 @pspp{} supplies a few functions for date arithmetic:
1066 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
1067 Returns the span of time from @var{date1} to @var{date2} in terms of
1068 @var{unit}, which must be a quoted string, one of @samp{years},
1069 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1070 @samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an
1071 integer, truncated toward zero.
1073 One year is considered to span from a given date to the same month,
1074 day, and time of day the next year. Thus, from Jan.@tie{}1 of one
1075 year to Jan.@tie{}1 the next year is considered to be a full year, but
1076 Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not.
1077 Similarly, one month spans from a given day of the month to the same
1078 day of the following month. Thus, there is never a full month from
1079 Jan.@tie{}31 of a given year to any day in the following February.
1082 @deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}])
1083 Returns @var{date} advanced by the given @var{quantity} of the
1084 specified @var{unit}, which must be one of the strings @samp{years},
1085 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1086 @samp{hours}, @samp{minutes}, and @samp{seconds}.
1088 When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months},
1089 only the integer part of @var{quantity} is considered. Adding one of
1090 these units can cause the day of the month to exceed the number of
1091 days in the month. In this case, the @var{method} comes into
1092 play: if it is omitted or specified as @samp{closest} (as a quoted
1093 string), then the resulting day is the last day of the month;
1094 otherwise, if it is specified as @samp{rollover}, then the extra days
1095 roll over into the following month.
1097 When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours},
1098 @samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded
1099 to an integer and @var{method}, if specified, is ignored.
1102 @node Miscellaneous Functions
1103 @subsection Miscellaneous Functions
1104 @cindex functions, miscellaneous
1106 @cindex cross-case function
1107 @cindex function, cross-case
1108 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1111 @var{variable} must be a numeric or string variable name. @code{LAG}
1112 yields the value of that variable for the case @var{n} before the
1113 current one. Results in system-missing (for numeric variables) or
1114 blanks (for string variables) for the first @var{n} cases.
1116 @code{LAG} obtains values from the cases that become the new active
1118 after a procedure executes. Thus, @code{LAG} will not return values
1119 from cases dropped by transformations such as @cmd{SELECT IF}, and
1120 transformations like @cmd{COMPUTE} that modify data will change the
1121 values returned by @code{LAG}. These are both the case whether these
1122 transformations precede or follow the use of @code{LAG}.
1124 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1125 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1126 used after @cmd{TEMPORARY}.
1128 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1129 be a small positive constant integer. There is no explicit limit, but
1130 use of a large value will increase memory consumption.
1133 @cindex date, Julian
1135 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1136 @var{year} is a year, either between 0 and 99 or at least 1582.
1137 Unlike other @pspp{} date functions, years between 0 and 99 always
1138 correspond to 1900 through 1999. @var{month} is a month between 1 and
1139 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1140 the last day of the previous month, and a @var{month} of 13 refers to
1141 the first month of the next year. @var{year} must be in range.
1142 @var{year}, @var{month}, and @var{day} must all be integers.
1144 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1145 the date specified, plus one. The date passed to @code{YRMODA} must be
1146 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1150 @deftypefn {Function} VALUELABEL (@var{variable})
1151 Returns a string matching the label associated with the current value
1152 of @var{variable}. If the current value of @var{variable} has no
1153 associated label, then this function returns the empty string.
1154 @var{variable} may be a numeric or string variable.
1157 @node Statistical Distribution Functions
1158 @subsection Statistical Distribution Functions
1160 @pspp{} can calculate several functions of standard statistical
1161 distributions. These functions are named systematically based on the
1162 function and the distribution. The table below describes the
1163 statistical distribution functions in general:
1166 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1167 Probability density function for @var{dist}. The domain of @var{x}
1168 depends on @var{dist}. For continuous distributions, the result is
1169 the density of the probability function at @var{x}, and the range is
1170 nonnegative real numbers. For discrete distributions, the result is
1171 the probability of @var{x}.
1173 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1174 Cumulative distribution function for @var{dist}, that is, the
1175 probability that a random variate drawn from the distribution is less
1176 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1179 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1180 Tail probability function for @var{dist}, that is, the probability
1181 that a random variate drawn from the distribution is greater than
1182 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1183 probability. Only a few distributions include an @func{SIG} function.
1185 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1186 Inverse distribution function for @var{dist}, the value of @var{x} for
1187 which the CDF would yield @var{p}. The value of @var{p} is a
1188 probability. The range depends on @var{dist} and is identical to the
1189 domain for the corresponding CDF.
1191 @item RV.@var{dist} ([@var{param}@dots{}])
1192 Random variate function for @var{dist}. The range depends on the
1195 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1196 Noncentral probability density function. The result is the density of
1197 the given noncentral distribution at @var{x}. The domain of @var{x}
1198 depends on @var{dist}. The range is nonnegative real numbers. Only a
1199 few distributions include an @func{NPDF} function.
1201 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1202 Noncentral cumulative distribution function for @var{dist}, that is,
1203 the probability that a random variate drawn from the given noncentral
1204 distribution is less than @var{x}. The domain of @var{x} depends
1205 @var{dist}. The result is a probability. Only a few distributions
1206 include an NCDF function.
1209 The individual distributions are described individually below.
1212 * Continuous Distributions::
1213 * Discrete Distributions::
1216 @node Continuous Distributions
1217 @subsubsection Continuous Distributions
1219 The following continuous distributions are available:
1221 @deftypefn {Function} {} PDF.BETA (@var{x})
1222 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1223 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1224 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1225 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1226 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1227 Beta distribution with shape parameters @var{a} and @var{b}. The
1228 noncentral distribution takes an additional parameter @var{lambda}.
1229 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1230 <= 1, 0 <= @var{p} <= 1.
1233 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1234 @deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
1235 Bivariate normal distribution of two standard normal variables with
1236 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1237 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1240 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1241 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1242 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1243 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1244 Cauchy distribution with location parameter @var{a} and scale
1245 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1248 @c @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1249 @deftypefn {Function} {} CDF.CHISQ (@var{x}, @var{df})
1250 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1251 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1252 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1253 @c @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1254 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1255 Chi-squared distribution with @var{df} degrees of freedom. The
1256 noncentral distribution takes an additional parameter @var{lambda}.
1257 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1261 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1262 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1263 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1264 @deftypefnx {Function} {} RV.EXP (@var{a})
1265 Exponential distribution with scale parameter @var{a}. The inverse of
1266 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1267 @var{x} >= 0, 0 <= @var{p} < 1.
1270 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1271 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1272 Exponential power distribution with positive scale parameter @var{a}
1273 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1274 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1278 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1279 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1280 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1281 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1282 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1283 @c @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1284 @c @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1285 F-distribution of two chi-squared deviates with @var{df1} and
1286 @var{df2} degrees of freedom. The noncentral distribution takes an
1287 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1288 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1291 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1292 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1293 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1294 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1295 Gamma distribution with shape parameter @var{a} and scale parameter
1296 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1300 @c @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1301 @c @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1302 @c @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1303 @c @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1304 @c Half-normal distribution with location parameter @var{a} and shape
1305 @c parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1308 @c @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1309 @c @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1310 @c @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1311 @c @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1312 @c Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1313 @c Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1316 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1317 @deftypefnx {Function} {} RV.LANDAU ()
1318 Landau distribution.
1321 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1322 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1323 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1324 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1325 Laplace distribution with location parameter @var{a} and scale
1326 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1329 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1330 Levy symmetric alpha-stable distribution with scale @var{c} and
1331 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1334 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1335 Levy skew alpha-stable distribution with scale @var{c}, exponent
1336 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1337 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1340 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1341 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1342 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1343 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1344 Logistic distribution with location parameter @var{a} and scale
1345 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1348 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1349 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1350 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1351 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1352 Lognormal distribution with parameters @var{a} and @var{b}.
1353 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1356 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1357 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1358 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1359 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1360 Normal distribution with mean @var{mu} and standard deviation
1361 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1362 additional functions are available as shorthand:
1364 @deftypefn {Function} {} CDFNORM (@var{x})
1365 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1368 @deftypefn {Function} {} PROBIT (@var{p})
1369 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1372 @deftypefn {Function} {} NORMAL (@var{sigma})
1373 Equivalent to RV.NORMAL(0, @var{sigma}).
1377 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1378 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1379 Normal tail distribution with lower limit @var{a} and standard
1380 deviation @var{sigma}. This distribution is a @pspp{} extension.
1381 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1384 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1385 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1386 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1387 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1388 Pareto distribution with threshold parameter @var{a} and shape
1389 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1390 @var{a}, 0 <= @var{p} < 1.
1393 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1394 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1395 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1396 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1397 Rayleigh distribution with scale parameter @var{sigma}. This
1398 distribution is a @pspp{} extension. Constraints: @var{sigma} > 0,
1402 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1403 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1404 Rayleigh tail distribution with lower limit @var{a} and scale
1405 parameter @var{sigma}. This distribution is a @pspp{} extension.
1406 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1409 @c @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1410 @c @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1411 @c Studentized maximum modulus distribution with parameters @var{a} and
1412 @c @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1416 @c @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1417 @c @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1418 @c Studentized range distribution with parameters @var{a} and @var{b}.
1419 @c Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1423 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1424 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1425 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1426 @deftypefnx {Function} {} RV.T (@var{df})
1427 @c @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1428 @c @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1429 T-distribution with @var{df} degrees of freedom. The noncentral
1430 distribution takes an additional parameter @var{lambda}. Constraints:
1431 @var{df} > 0, 0 < @var{p} < 1.
1434 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1435 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1436 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1437 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1438 distribution is a @pspp{} extension. Constraints: 0 < @var{p} < 1.
1441 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1442 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1443 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1444 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1445 distribution is a @pspp{} extension. Constraints: @var{x} > 0, 0 <
1449 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1450 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1451 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1452 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1453 Uniform distribution with parameters @var{a} and @var{b}.
1454 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1455 additional function is available as shorthand:
1457 @deftypefn {Function} {} UNIFORM (@var{b})
1458 Equivalent to RV.UNIFORM(0, @var{b}).
1462 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1463 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1464 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1465 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1466 Weibull distribution with parameters @var{a} and @var{b}.
1467 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1470 @node Discrete Distributions
1471 @subsubsection Discrete Distributions
1473 The following discrete distributions are available:
1475 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1476 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1477 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1478 Bernoulli distribution with probability of success @var{p}.
1479 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1482 @deftypefn {Function} {} PDF.BINOM (@var{x}, @var{n}, @var{p})
1483 @deftypefnx {Function} {} CDF.BINOM (@var{x}, @var{n}, @var{p})
1484 @deftypefnx {Function} {} RV.BINOM (@var{n}, @var{p})
1485 Binomial distribution with @var{n} trials and probability of success
1486 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1490 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1491 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1492 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1493 Geometric distribution with probability of success @var{p}.
1494 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1497 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1498 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1499 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1500 Hypergeometric distribution when @var{b} objects out of @var{a} are
1501 drawn and @var{c} of the available objects are distinctive.
1502 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1503 @var{c} <= @var{a}, integer @var{x} >= 0.
1506 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1507 @deftypefnx {Function} {} RV.LOG (@var{p})
1508 Logarithmic distribution with probability parameter @var{p}.
1509 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1512 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1513 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1514 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1515 Negative binomial distribution with number of successes parameter
1516 @var{n} and probability of success parameter @var{p}. Constraints:
1517 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1520 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1521 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1522 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1523 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1524 integer @var{x} >= 0.
1527 @node Order of Operations
1528 @section Operator Precedence
1529 @cindex operator precedence
1530 @cindex precedence, operator
1531 @cindex order of operations
1532 @cindex operations, order of
1534 The following table describes operator precedence. Smaller-numbered
1535 levels in the table have higher precedence. Within a level,
1536 operations are always performed from left to right. The first
1537 occurrence of @samp{-} represents unary negation, the second binary
1552 @code{EQ GE GT LE LT NE}