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 SUBSTR UPCASE
268 * Time and Date:: CTIME.xxx DATE.xxx TIME.xxx XDATE.xxx
270 * Miscellaneous Functions:: LAG YRMODA VALUELABEL
271 * Statistical Distribution Functions:: PDF CDF SIG IDF RV NPDF NCDF
275 @subsection Mathematical Functions
276 @cindex mathematics, advanced
278 Advanced mathematical functions take numeric arguments and produce
281 @deftypefn {Function} {} EXP (@var{exponent})
282 Returns @math{e} (approximately 2.71828) raised to power @var{exponent}.
286 @deftypefn {Function} {} LG10 (@var{number})
287 Takes the base-10 logarithm of @var{number}. If @var{number} is
288 not positive, the result is system-missing.
291 @deftypefn {Function} {} LN (@var{number})
292 Takes the base-@math{e} logarithm of @var{number}. If @var{number} is
293 not positive, the result is system-missing.
296 @deftypefn {Function} {} LNGAMMA (@var{number})
297 Yields the base-@math{e} logarithm of the complete gamma of @var{number}.
298 If @var{number} is a negative integer, the result is system-missing.
302 @deftypefn {Function} {} SQRT (@var{number})
303 Takes the square root of @var{number}. If @var{number} is negative,
304 the result is system-missing.
307 @node Miscellaneous Mathematics
308 @subsection Miscellaneous Mathematical Functions
309 @cindex mathematics, miscellaneous
311 Miscellaneous mathematical functions take numeric arguments and produce
314 @cindex absolute value
315 @deftypefn {Function} {} ABS (@var{number})
316 Results in the absolute value of @var{number}.
320 @deftypefn {Function} {} MOD (@var{numerator}, @var{denominator})
321 Returns the remainder (modulus) of @var{numerator} divided by
322 @var{denominator}. If @var{numerator} is 0, then the result is 0,
323 even if @var{denominator} is missing. If @var{denominator} is 0, the
324 result is system-missing.
327 @cindex modulus, by 10
328 @deftypefn {Function} {} MOD10 (@var{number})
329 Returns the remainder when @var{number} is divided by 10. If
330 @var{number} is negative, MOD10(@var{number}) is negative or zero.
334 @deftypefn {Function} {} RND (@var{number} [, @var{mult}[, @var{fuzzbits}]])
335 Rounds @var{number} and rounds it to a multiple of @var{mult} (by
336 default 1). Halves are rounded away from zero, as are values that
337 fall short of halves by less than @var{fuzzbits} of errors in the
338 least-significant bits of @var{number}. If @var{fuzzbits} is not
339 specified then the default is taken from SET FUZZBITS (@pxref{SET
340 FUZZBITS}), which is 6 unless overridden.
344 @deftypefn {Function} {} TRUNC (@var{number})
345 Discards the fractional part of @var{number}; that is, rounds
346 @var{number} towards zero.
350 @subsection Trigonometric Functions
353 Trigonometric functions take numeric arguments and produce numeric
357 @cindex inverse cosine
358 @deftypefn {Function} {} ARCOS (@var{number})
359 @deftypefnx {Function} {} ACOS (@var{number})
360 Takes the arccosine, in radians, of @var{number}. Results in
361 system-missing if @var{number} is not between -1 and 1 inclusive.
362 This function is a @pspp{} extension.
367 @deftypefn {Function} {} ARSIN (@var{number})
368 @deftypefnx {Function} {} ASIN (@var{number})
369 Takes the arcsine, in radians, of @var{number}. Results in
370 system-missing if @var{number} is not between -1 and 1 inclusive.
374 @cindex inverse tangent
375 @deftypefn {Function} {} ARTAN (@var{number})
376 @deftypefnx {Function} {} ATAN (@var{number})
377 Takes the arctangent, in radians, of @var{number}.
381 @deftypefn {Function} {} COS (@var{angle})
382 Takes the cosine of @var{angle} which should be in radians.
386 @deftypefn {Function} {} SIN (@var{angle})
387 Takes the sine of @var{angle} which should be in radians.
391 @deftypefn {Function} {} TAN (@var{angle})
392 Takes the tangent of @var{angle} which should be in radians.
393 Results in system-missing at values
394 of @var{angle} that are too close to odd multiples of @math{\pi/2}.
398 @node Missing Value Functions
399 @subsection Missing-Value Functions
400 @cindex missing values
401 @cindex values, missing
402 @cindex functions, missing-value
404 Missing-value functions take various numeric arguments and yield
405 various types of results. Except where otherwise stated below, the
406 normal rules of evaluation apply within expression arguments to these
407 functions. In particular, user-missing values for numeric variables
408 are converted to system-missing values.
410 @deftypefn {Function} {} MISSING (@var{expr})
411 Returns 1 if @var{expr} has the system-missing value, 0 otherwise.
414 @deftypefn {Function} {} NMISS (@var{expr} [, @var{expr}]@dots{})
415 Each argument must be a numeric expression. Returns the number of
416 system-missing values in the list, which may include variable ranges
417 using the @code{@var{var1} TO @var{var2}} syntax.
420 @deftypefn {Function} {} NVALID (@var{expr} [, @var{expr}]@dots{})
421 Each argument must be a numeric expression. Returns the number of
422 values in the list that are not system-missing. The list may include
423 variable ranges using the @code{@var{var1} TO @var{var2}} syntax.
426 @deftypefn {Function} {} SYSMIS (@var{expr})
427 When @var{expr} is simply the name of a numeric variable, returns 1 if
428 the variable has the system-missing value, 0 if it is user-missing or
429 not missing. If given @var{expr} takes another form, results in 1 if
430 the value is system-missing, 0 otherwise.
433 @deftypefn {Function} {} VALUE (@var{variable})
434 Prevents the user-missing values of @var{variable} from being
435 transformed into system-missing values, and always results in the
436 actual value of @var{variable}, whether it is valid, user-missing, or
441 @subsection Set-Membership Functions
442 @cindex set membership
443 @cindex membership, of set
445 Set membership functions determine whether a value is a member of a set.
446 They take a set of numeric arguments or a set of string arguments, and
447 produce Boolean results.
449 String comparisons are performed according to the rules given in
450 @ref{Relational Operators}.
452 @deftypefn {Function} {} ANY (@var{value}, @var{set} [, @var{set}]@dots{})
453 Results in true if @var{value} is equal to any of the @var{set}
454 values. Otherwise, results in false. If @var{value} is
455 system-missing, returns system-missing. System-missing values in
456 @var{set} do not cause @func{ANY} to return system-missing.
459 @deftypefn {Function} {} RANGE (@var{value}, @var{low}, @var{high} [, @var{low}, @var{high}]@dots{})
460 Results in true if @var{value} is in any of the intervals bounded by
461 @var{low} and @var{high} inclusive. Otherwise, results in false.
462 Each @var{low} must be less than or equal to its corresponding
463 @var{high} value. @var{low} and @var{high} must be given in pairs.
464 If @var{value} is system-missing, returns system-missing.
465 System-missing values in @var{set} do not cause @func{RANGE} to return
469 @node Statistical Functions
470 @subsection Statistical Functions
471 @cindex functions, statistical
474 Statistical functions compute descriptive statistics on a list of
475 values. Some statistics can be computed on numeric or string values;
476 other can only be computed on numeric values. Their results have the
477 same type as their arguments. The current case's weighting factor
478 (@pxref{WEIGHT}) has no effect on statistical functions.
480 These functions' argument lists may include entire ranges of variables
481 using the @code{@var{var1} TO @var{var2}} syntax.
483 @cindex arguments, minimum valid
484 @cindex minimum valid number of arguments
485 Unlike most functions, statistical functions can return non-missing
486 values even when some of their arguments are missing. Most
487 statistical functions, by default, require only 1 non-missing value to
488 have a non-missing return, but @func{CFVAR}, @func{SD}, and @func {VARIANCE} require 2.
489 These defaults can be increased (but not decreased) by appending a dot
490 and the minimum number of valid arguments to the function name. For
491 example, @subcmd{MEAN.3(X, Y, Z)} would only return non-missing if all
492 of @samp{X}, @samp{Y}, and @samp{Z} were valid.
494 @cindex coefficient of variation
495 @cindex variation, coefficient of
496 @deftypefn {Function} {} CFVAR (@var{number}, @var{number}[, @dots{}])
497 Results in the coefficient of variation of the values of @var{number}.
498 (The coefficient of variation is the standard deviation divided by the
503 @deftypefn {Function} {} MAX (@var{value}, @var{value}[, @dots{}])
504 Results in the value of the greatest @var{value}. The @var{value}s may
505 be numeric or string.
509 @deftypefn {Function} {} MEAN (@var{number}, @var{number}[, @dots{}])
510 Results in the mean of the values of @var{number}.
514 @deftypefn {Function} {} MEDIAN (@var{number}, @var{number}[, @dots{}])
515 Results in the median of the values of @var{number}. Given an even
516 number of nonmissing arguments, yields the mean of the two middle
521 @deftypefn {Function} {} MIN (@var{number}, @var{number}[, @dots{}])
522 Results in the value of the least @var{value}. The @var{value}s may
523 be numeric or string.
526 @cindex standard deviation
527 @cindex deviation, standard
528 @deftypefn {Function} {} SD (@var{number}, @var{number}[, @dots{}])
529 Results in the standard deviation of the values of @var{number}.
533 @deftypefn {Function} {} SUM (@var{number}, @var{number}[, @dots{}])
534 Results in the sum of the values of @var{number}.
538 @deftypefn {Function} {} VARIANCE (@var{number}, @var{number}[, @dots{}])
539 Results in the variance of the values of @var{number}.
542 @node String Functions
543 @subsection String Functions
544 @cindex functions, string
545 @cindex string functions
547 String functions take various arguments and return various results.
549 @cindex concatenation
550 @cindex strings, concatenation of
551 @deftypefn {Function} {} CONCAT (@var{string}, @var{string}[, @dots{}])
552 Returns a string consisting of each @var{string} in sequence.
553 @code{CONCAT("abc", "def", "ghi")} has a value of @code{"abcdefghi"}.
554 The resultant string is truncated to a maximum of 255 characters.
557 @cindex searching strings
558 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needle})
559 Returns a positive integer indicating the position of the first
560 occurrence of @var{needle} in @var{haystack}. Returns 0 if @var{haystack}
561 does not contain @var{needle}. Returns system-missing if @var{needle}
565 @deftypefn {Function} {} INDEX (@var{haystack}, @var{needles}, @var{needle_len})
566 Divides @var{needles} into one or more needles, each with length
568 Searches @var{haystack} for the first occurrence of each needle, and
569 returns the smallest value. Returns 0 if @var{haystack} does not
570 contain any part in @var{needle}. It is an error if @var{needle_len}
571 does not evenly divide the length of @var{needles}. Returns
572 system-missing if @var{needles} is an empty string.
575 @cindex strings, finding length of
576 @deftypefn {Function} {} LENGTH (@var{string})
577 Returns the number of characters in @var{string}.
580 @cindex strings, case of
581 @deftypefn {Function} {} LOWER (@var{string})
582 Returns a string identical to @var{string} except that all uppercase
583 letters are changed to lowercase letters. The definitions of
584 ``uppercase'' and ``lowercase'' are system-dependent.
587 @cindex strings, padding
588 @deftypefn {Function} {} LPAD (@var{string}, @var{length})
589 If @var{string} is at least @var{length} characters in length, returns
590 @var{string} unchanged. Otherwise, returns @var{string} padded with
591 spaces on the left side to length @var{length}. Returns an empty string
592 if @var{length} is system-missing, negative, or greater than 255.
595 @deftypefn {Function} {} LPAD (@var{string}, @var{length}, @var{padding})
596 If @var{string} is at least @var{length} characters in length, returns
597 @var{string} unchanged. Otherwise, returns @var{string} padded with
598 @var{padding} on the left side to length @var{length}. Returns an empty
599 string if @var{length} is system-missing, negative, or greater than 255, or
600 if @var{padding} does not contain exactly one character.
603 @cindex strings, trimming
604 @cindex white space, trimming
605 @deftypefn {Function} {} LTRIM (@var{string})
606 Returns @var{string}, after removing leading spaces. Other white space,
607 such as tabs, carriage returns, line feeds, and vertical tabs, is not
611 @deftypefn {Function} {} LTRIM (@var{string}, @var{padding})
612 Returns @var{string}, after removing leading @var{padding} characters.
613 If @var{padding} does not contain exactly one character, returns an
617 @cindex numbers, converting from strings
618 @cindex strings, converting to numbers
619 @deftypefn {Function} {} NUMBER (@var{string}, @var{format})
620 Returns the number produced when @var{string} is interpreted according
621 to format specifier @var{format}. If the format width @var{w} is less
622 than the length of @var{string}, then only the first @var{w}
623 characters in @var{string} are used, e.g.@: @code{NUMBER("123", F3.0)}
624 and @code{NUMBER("1234", F3.0)} both have value 123. If @var{w} is
625 greater than @var{string}'s length, then it is treated as if it were
626 right-padded with spaces. If @var{string} is not in the correct
627 format for @var{format}, system-missing is returned.
630 @cindex strings, replacing substrings
631 @cindex replacing substrings
632 @deftypefn {Function} {} REPLACE (@var{haystack}, @var{needle}, @var{replacement}[, @var{n}])
633 Returns string @var{haystack} with instances of @var{needle} replaced
634 by @var{replacement}. If nonnegative integer @var{n} is specified, it
635 limits the maximum number of replacements; otherwise, all instances of
636 @var{needle} are replaced.
639 @cindex strings, searching backwards
640 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle})
641 Returns a positive integer indicating the position of the last
642 occurrence of @var{needle} in @var{haystack}. Returns 0 if
643 @var{haystack} does not contain @var{needle}. Returns system-missing if
644 @var{needle} is an empty string.
647 @deftypefn {Function} {} RINDEX (@var{haystack}, @var{needle}, @var{needle_len})
648 Divides @var{needle} into parts, each with length @var{needle_len}.
649 Searches @var{haystack} for the last occurrence of each part, and
650 returns the largest value. Returns 0 if @var{haystack} does not contain
651 any part in @var{needle}. It is an error if @var{needle_len} does not
652 evenly divide the length of @var{needle}. Returns system-missing
653 if @var{needle} is an empty string or if needle_len is less than 1.
656 @cindex padding strings
657 @cindex strings, padding
658 @deftypefn {Function} {} RPAD (@var{string}, @var{length})
659 If @var{string} is at least @var{length} characters in length, returns
660 @var{string} unchanged. Otherwise, returns @var{string} padded with
661 spaces on the right to length @var{length}. Returns an empty string if
662 @var{length} is system-missing, negative, or greater than 255.
665 @deftypefn {Function} {} RPAD (@var{string}, @var{length}, @var{padding})
666 If @var{string} is at least @var{length} characters in length, returns
667 @var{string} unchanged. Otherwise, returns @var{string} padded with
668 @var{padding} on the right to length @var{length}. Returns an empty
669 string if @var{length} is system-missing, negative, or greater than 255,
670 or if @var{padding} does not contain exactly one character.
673 @cindex strings, trimming
674 @cindex white space, trimming
675 @deftypefn {Function} {} RTRIM (@var{string})
676 Returns @var{string}, after removing trailing spaces. Other types of
677 white space are not removed.
680 @deftypefn {Function} {} RTRIM (@var{string}, @var{padding})
681 Returns @var{string}, after removing trailing @var{padding} characters.
682 If @var{padding} does not contain exactly one character, returns an
686 @cindex strings, converting from numbers
687 @cindex numbers, converting to strings
688 @deftypefn {Function} {} STRING (@var{number}, @var{format})
689 Returns a string corresponding to @var{number} in the format given by
690 format specifier @var{format}. For example, @code{STRING(123.56, F5.1)}
691 has the value @code{"123.6"}.
695 @cindex strings, taking substrings of
696 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start})
697 Returns a string consisting of the value of @var{string} from position
698 @var{start} onward. Returns an empty string if @var{start} is system-missing,
699 less than 1, or greater than the length of @var{string}.
702 @deftypefn {Function} {} SUBSTR (@var{string}, @var{start}, @var{count})
703 Returns a string consisting of the first @var{count} characters from
704 @var{string} beginning at position @var{start}. Returns an empty string
705 if @var{start} or @var{count} is system-missing, if @var{start} is less
706 than 1 or greater than the number of characters in @var{string}, or if
707 @var{count} is less than 1. Returns a string shorter than @var{count}
708 characters if @var{start} + @var{count} - 1 is greater than the number
709 of characters in @var{string}. Examples: @code{SUBSTR("abcdefg", 3, 2)}
710 has value @code{"cd"}; @code{SUBSTR("nonsense", 4, 10)} has the value
714 @cindex case conversion
715 @cindex strings, case of
716 @deftypefn {Function} {} UPCASE (@var{string})
717 Returns @var{string}, changing lowercase letters to uppercase letters.
721 @subsection Time & Date Functions
722 @cindex functions, time & date
727 For compatibility, @pspp{} considers dates before 15 Oct 1582 invalid.
728 Most time and date functions will not accept earlier dates.
731 * Time and Date Concepts:: How times & dates are defined and represented
732 * Time Construction:: TIME.@{DAYS HMS@}
733 * Time Extraction:: CTIME.@{DAYS HOURS MINUTES SECONDS@}
734 * Date Construction:: DATE.@{DMY MDY MOYR QYR WKYR YRDAY@}
735 * Date Extraction:: XDATE.@{DATE HOUR JDAY MDAY MINUTE MONTH
736 QUARTER SECOND TDAY TIME WEEK
738 * Time and Date Arithmetic:: DATEDIFF DATESUM
741 @node Time and Date Concepts
742 @subsubsection How times & dates are defined and represented
744 @cindex time, concepts
745 @cindex time, intervals
746 Times and dates are handled by @pspp{} as single numbers. A
747 @dfn{time} is an interval. @pspp{} measures times in seconds.
748 Thus, the following intervals correspond with the numeric values given:
753 1 day, 3 hours, 10 seconds 97,210
757 @cindex dates, concepts
758 @cindex time, instants of
759 A @dfn{date}, on the other hand, is a particular instant in the past
760 or the future. @pspp{} represents a date as a number of seconds since
761 midnight preceding 14 Oct 1582. Because midnight preceding the dates
762 given below correspond with the numeric @pspp{} dates given:
766 4 Jul 1776 6,113,318,400
767 1 Jan 1900 10,010,390,400
768 1 Oct 1978 12,495,427,200
769 24 Aug 1995 13,028,601,600
772 @node Time Construction
773 @subsubsection Functions that Produce Times
774 @cindex times, constructing
775 @cindex constructing times
777 These functions take numeric arguments and return numeric values that
781 @cindex time, in days
782 @deftypefn {Function} {} TIME.DAYS (@var{ndays})
783 Returns a time corresponding to @var{ndays} days.
786 @cindex hours-minutes-seconds
787 @cindex time, in hours-minutes-seconds
788 @deftypefn {Function} {} TIME.HMS (@var{nhours}, @var{nmins}, @var{nsecs})
789 Returns a time corresponding to @var{nhours} hours, @var{nmins}
790 minutes, and @var{nsecs} seconds. The arguments may not have mixed
791 signs: if any of them are positive, then none may be negative, and
795 @node Time Extraction
796 @subsubsection Functions that Examine Times
797 @cindex extraction, of time
798 @cindex time examination
799 @cindex examination, of times
800 @cindex time, lengths of
802 These functions take numeric arguments in @pspp{} time format and
803 give numeric results.
806 @cindex time, in days
807 @deftypefn {Function} {} CTIME.DAYS (@var{time})
808 Results in the number of days and fractional days in @var{time}.
812 @cindex time, in hours
813 @deftypefn {Function} {} CTIME.HOURS (@var{time})
814 Results in the number of hours and fractional hours in @var{time}.
818 @cindex time, in minutes
819 @deftypefn {Function} {} CTIME.MINUTES (@var{time})
820 Results in the number of minutes and fractional minutes in @var{time}.
824 @cindex time, in seconds
825 @deftypefn {Function} {} CTIME.SECONDS (@var{time})
826 Results in the number of seconds and fractional seconds in @var{time}.
827 (@code{CTIME.SECONDS} does nothing; @code{CTIME.SECONDS(@var{x})} is
828 equivalent to @code{@var{x}}.)
831 @node Date Construction
832 @subsubsection Functions that Produce Dates
833 @cindex dates, constructing
834 @cindex constructing dates
836 @cindex arguments, of date construction functions
837 These functions take numeric arguments and give numeric results that
838 represent dates. Arguments taken by these functions are:
842 Refers to a day of the month between 1 and 31. Day 0 is also accepted
843 and refers to the final day of the previous month. Days 29, 30, and
844 31 are accepted even in months that have fewer days and refer to a day
845 near the beginning of the following month.
848 Refers to a month of the year between 1 and 12. Months 0 and 13 are
849 also accepted and refer to the last month of the preceding year and
850 the first month of the following year, respectively.
853 Refers to a quarter of the year between 1 and 4. The quarters of the
854 year begin on the first day of months 1, 4, 7, and 10.
857 Refers to a week of the year between 1 and 53.
860 Refers to a day of the year between 1 and 366.
863 Refers to a year, 1582 or greater. Years between 0 and 99 are treated
864 according to the epoch set on SET EPOCH, by default beginning 69 years
865 before the current date (@pxref{SET EPOCH}).
868 @cindex arguments, invalid
869 If these functions' arguments are out-of-range, they are correctly
870 normalized before conversion to date format. Non-integers are rounded
873 @cindex day-month-year
874 @cindex dates, day-month-year
875 @deftypefn {Function} {} DATE.DMY (@var{day}, @var{month}, @var{year})
876 @deftypefnx {Function} {} DATE.MDY (@var{month}, @var{day}, @var{year})
877 Results in a date value corresponding to the midnight before day
878 @var{day} of month @var{month} of year @var{year}.
882 @cindex dates, month-year
883 @deftypefn {Function} {} DATE.MOYR (@var{month}, @var{year})
884 Results in a date value corresponding to the midnight before the first
885 day of month @var{month} of year @var{year}.
889 @cindex dates, quarter-year
890 @deftypefn {Function} {} DATE.QYR (@var{quarter}, @var{year})
891 Results in a date value corresponding to the midnight before the first
892 day of quarter @var{quarter} of year @var{year}.
896 @cindex dates, week-year
897 @deftypefn {Function} {} DATE.WKYR (@var{week}, @var{year})
898 Results in a date value corresponding to the midnight before the first
899 day of week @var{week} of year @var{year}.
903 @cindex dates, year-day
904 @deftypefn {Function} {} DATE.YRDAY (@var{year}, @var{yday})
905 Results in a date value corresponding to the day
906 @var{yday} of year @var{year}.
909 @node Date Extraction
910 @subsubsection Functions that Examine Dates
911 @cindex extraction, of dates
912 @cindex date examination
914 @cindex arguments, of date extraction functions
915 These functions take numeric arguments in @pspp{} date or time
916 format and give numeric results. These names are used for arguments:
920 A numeric value in @pspp{} date format.
923 A numeric value in @pspp{} time format.
926 A numeric value in @pspp{} time or date format.
930 @cindex dates, in days
931 @cindex time, in days
932 @deftypefn {Function} {} XDATE.DATE (@var{time-or-date})
933 For a time, results in the time corresponding to the number of whole
934 days @var{date-or-time} includes. For a date, results in the date
935 corresponding to the latest midnight at or before @var{date-or-time};
936 that is, gives the date that @var{date-or-time} is in.
940 @cindex dates, in hours
941 @cindex time, in hours
942 @deftypefn {Function} {} XDATE.HOUR (@var{time-or-date})
943 For a time, results in the number of whole hours beyond the number of
944 whole days represented by @var{date-or-time}. For a date, results in
945 the hour (as an integer between 0 and 23) corresponding to
949 @cindex day of the year
950 @cindex dates, day of the year
951 @deftypefn {Function} {} XDATE.JDAY (@var{date})
952 Results in the day of the year (as an integer between 1 and 366)
953 corresponding to @var{date}.
956 @cindex day of the month
957 @cindex dates, day of the month
958 @deftypefn {Function} {} XDATE.MDAY (@var{date})
959 Results in the day of the month (as an integer between 1 and 31)
960 corresponding to @var{date}.
964 @cindex dates, in minutes
965 @cindex time, in minutes
966 @deftypefn {Function} {} XDATE.MINUTE (@var{time-or-date})
967 Results in the number of minutes (as an integer between 0 and 59) after
968 the last hour in @var{time-or-date}.
972 @cindex dates, in months
973 @deftypefn {Function} {} XDATE.MONTH (@var{date})
974 Results in the month of the year (as an integer between 1 and 12)
975 corresponding to @var{date}.
979 @cindex dates, in quarters
980 @deftypefn {Function} {} XDATE.QUARTER (@var{date})
981 Results in the quarter of the year (as an integer between 1 and 4)
982 corresponding to @var{date}.
986 @cindex dates, in seconds
987 @cindex time, in seconds
988 @deftypefn {Function} {} XDATE.SECOND (@var{time-or-date})
989 Results in the number of whole seconds after the last whole minute (as
990 an integer between 0 and 59) in @var{time-or-date}.
994 @cindex times, in days
995 @deftypefn {Function} {} XDATE.TDAY (@var{date})
996 Results in the number of whole days from 14 Oct 1582 to @var{date}.
1000 @cindex dates, time of day
1001 @deftypefn {Function} {} XDATE.TIME (@var{date})
1002 Results in the time of day at the instant corresponding to @var{date},
1003 as a time value. This is the number of seconds since
1004 midnight on the day corresponding to @var{date}.
1008 @cindex dates, in weeks
1009 @deftypefn {Function} {} XDATE.WEEK (@var{date})
1010 Results in the week of the year (as an integer between 1 and 53)
1011 corresponding to @var{date}.
1014 @cindex day of the week
1016 @cindex dates, day of the week
1017 @cindex dates, in weekdays
1018 @deftypefn {Function} {} XDATE.WKDAY (@var{date})
1019 Results in the day of week (as an integer between 1 and 7) corresponding
1020 to @var{date}, where 1 represents Sunday.
1024 @cindex dates, in years
1025 @deftypefn {Function} {} XDATE.YEAR (@var{date})
1026 Returns the year (as an integer 1582 or greater) corresponding to
1030 @node Time and Date Arithmetic
1031 @subsubsection Time and Date Arithmetic
1033 @cindex time, mathematical properties of
1034 @cindex mathematics, applied to times & dates
1035 @cindex dates, mathematical properties of
1037 Ordinary arithmetic operations on dates and times often produce
1038 sensible results. Adding a time to, or subtracting one from, a date
1039 produces a new date that much earlier or later. The difference of two
1040 dates yields the time between those dates. Adding two times produces
1041 the combined time. Multiplying a time by a scalar produces a time
1042 that many times longer. Since times and dates are just numbers, the
1043 ordinary addition and subtraction operators are employed for these
1046 Adding two dates does not produce a useful result.
1048 Dates and times may have very large values. Thus,
1049 it is not a good idea to take powers of these values; also, the
1050 accuracy of some procedures may be affected. If necessary, convert
1051 times or dates in seconds to some other unit, like days or years,
1052 before performing analysis.
1054 @pspp{} supplies a few functions for date arithmetic:
1056 @deftypefn {Function} {} DATEDIFF (@var{date2}, @var{date1}, @var{unit})
1057 Returns the span of time from @var{date1} to @var{date2} in terms of
1058 @var{unit}, which must be a quoted string, one of @samp{years},
1059 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1060 @samp{hours}, @samp{minutes}, and @samp{seconds}. The result is an
1061 integer, truncated toward zero.
1063 One year is considered to span from a given date to the same month,
1064 day, and time of day the next year. Thus, from Jan.@tie{}1 of one
1065 year to Jan.@tie{}1 the next year is considered to be a full year, but
1066 Feb.@tie{}29 of a leap year to the following Feb.@tie{}28 is not.
1067 Similarly, one month spans from a given day of the month to the same
1068 day of the following month. Thus, there is never a full month from
1069 Jan.@tie{}31 of a given year to any day in the following February.
1072 @deftypefn {Function} {} DATESUM (@var{date}, @var{quantity}, @var{unit}[, @var{method}])
1073 Returns @var{date} advanced by the given @var{quantity} of the
1074 specified @var{unit}, which must be one of the strings @samp{years},
1075 @samp{quarters}, @samp{months}, @samp{weeks}, @samp{days},
1076 @samp{hours}, @samp{minutes}, and @samp{seconds}.
1078 When @var{unit} is @samp{years}, @samp{quarters}, or @samp{months},
1079 only the integer part of @var{quantity} is considered. Adding one of
1080 these units can cause the day of the month to exceed the number of
1081 days in the month. In this case, the @var{method} comes into
1082 play: if it is omitted or specified as @samp{closest} (as a quoted
1083 string), then the resulting day is the last day of the month;
1084 otherwise, if it is specified as @samp{rollover}, then the extra days
1085 roll over into the following month.
1087 When @var{unit} is @samp{weeks}, @samp{days}, @samp{hours},
1088 @samp{minutes}, or @samp{seconds}, the @var{quantity} is not rounded
1089 to an integer and @var{method}, if specified, is ignored.
1092 @node Miscellaneous Functions
1093 @subsection Miscellaneous Functions
1094 @cindex functions, miscellaneous
1096 @cindex cross-case function
1097 @cindex function, cross-case
1098 @deftypefn {Function} {} LAG (@var{variable}[, @var{n}])
1101 @var{variable} must be a numeric or string variable name. @code{LAG}
1102 yields the value of that variable for the case @var{n} before the
1103 current one. Results in system-missing (for numeric variables) or
1104 blanks (for string variables) for the first @var{n} cases.
1106 @code{LAG} obtains values from the cases that become the new active
1108 after a procedure executes. Thus, @code{LAG} will not return values
1109 from cases dropped by transformations such as @cmd{SELECT IF}, and
1110 transformations like @cmd{COMPUTE} that modify data will change the
1111 values returned by @code{LAG}. These are both the case whether these
1112 transformations precede or follow the use of @code{LAG}.
1114 If @code{LAG} is used before @cmd{TEMPORARY}, then the values it returns
1115 are those in cases just before @cmd{TEMPORARY}. @code{LAG} may not be
1116 used after @cmd{TEMPORARY}.
1118 If omitted, @var{ncases} defaults to 1. Otherwise, @var{ncases} must
1119 be a small positive constant integer. There is no explicit limit, but
1120 use of a large value will increase memory consumption.
1123 @cindex date, Julian
1125 @deftypefn {Function} {} YRMODA (@var{year}, @var{month}, @var{day})
1126 @var{year} is a year, either between 0 and 99 or at least 1582.
1127 Unlike other @pspp{} date functions, years between 0 and 99 always
1128 correspond to 1900 through 1999. @var{month} is a month between 1 and
1129 13. @var{day} is a day between 0 and 31. A @var{day} of 0 refers to
1130 the last day of the previous month, and a @var{month} of 13 refers to
1131 the first month of the next year. @var{year} must be in range.
1132 @var{year}, @var{month}, and @var{day} must all be integers.
1134 @code{YRMODA} results in the number of days between 15 Oct 1582 and
1135 the date specified, plus one. The date passed to @code{YRMODA} must be
1136 on or after 15 Oct 1582. 15 Oct 1582 has a value of 1.
1140 @deftypefn {Function} VALUELABEL (@var{variable})
1141 Returns a string matching the label associated with the current value
1142 of @var{variable}. If the current value of @var{variable} has no
1143 associated label, then this function returns the empty string.
1144 @var{variable} may be a numeric or string variable.
1147 @node Statistical Distribution Functions
1148 @subsection Statistical Distribution Functions
1150 @pspp{} can calculate several functions of standard statistical
1151 distributions. These functions are named systematically based on the
1152 function and the distribution. The table below describes the
1153 statistical distribution functions in general:
1156 @item PDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1157 Probability density function for @var{dist}. The domain of @var{x}
1158 depends on @var{dist}. For continuous distributions, the result is
1159 the density of the probability function at @var{x}, and the range is
1160 nonnegative real numbers. For discrete distributions, the result is
1161 the probability of @var{x}.
1163 @item CDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1164 Cumulative distribution function for @var{dist}, that is, the
1165 probability that a random variate drawn from the distribution is less
1166 than @var{x}. The domain of @var{x} depends @var{dist}. The result is
1169 @item SIG.@var{dist} (@var{x}[, @var{param}@dots{})
1170 Tail probability function for @var{dist}, that is, the probability
1171 that a random variate drawn from the distribution is greater than
1172 @var{x}. The domain of @var{x} depends @var{dist}. The result is a
1173 probability. Only a few distributions include an @func{SIG} function.
1175 @item IDF.@var{dist} (@var{p}[, @var{param}@dots{}])
1176 Inverse distribution function for @var{dist}, the value of @var{x} for
1177 which the CDF would yield @var{p}. The value of @var{p} is a
1178 probability. The range depends on @var{dist} and is identical to the
1179 domain for the corresponding CDF.
1181 @item RV.@var{dist} ([@var{param}@dots{}])
1182 Random variate function for @var{dist}. The range depends on the
1185 @item NPDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1186 Noncentral probability density function. The result is the density of
1187 the given noncentral distribution at @var{x}. The domain of @var{x}
1188 depends on @var{dist}. The range is nonnegative real numbers. Only a
1189 few distributions include an @func{NPDF} function.
1191 @item NCDF.@var{dist} (@var{x}[, @var{param}@dots{}])
1192 Noncentral cumulative distribution function for @var{dist}, that is,
1193 the probability that a random variate drawn from the given noncentral
1194 distribution is less than @var{x}. The domain of @var{x} depends
1195 @var{dist}. The result is a probability. Only a few distributions
1196 include an NCDF function.
1199 The individual distributions are described individually below.
1202 * Continuous Distributions::
1203 * Discrete Distributions::
1206 @node Continuous Distributions
1207 @subsubsection Continuous Distributions
1209 The following continuous distributions are available:
1211 @deftypefn {Function} {} PDF.BETA (@var{x})
1212 @deftypefnx {Function} {} CDF.BETA (@var{x}, @var{a}, @var{b})
1213 @deftypefnx {Function} {} IDF.BETA (@var{p}, @var{a}, @var{b})
1214 @deftypefnx {Function} {} RV.BETA (@var{a}, @var{b})
1215 @deftypefnx {Function} {} NPDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1216 @deftypefnx {Function} {} NCDF.BETA (@var{x}, @var{a}, @var{b}, @var{lambda})
1217 Beta distribution with shape parameters @var{a} and @var{b}. The
1218 noncentral distribution takes an additional parameter @var{lambda}.
1219 Constraints: @var{a} > 0, @var{b} > 0, @var{lambda} >= 0, 0 <= @var{x}
1220 <= 1, 0 <= @var{p} <= 1.
1223 @deftypefn {Function} {} PDF.BVNOR (@var{x0}, @var{x1}, @var{rho})
1224 @deftypefnx {Function} {} CDF.VBNOR (@var{x0}, @var{x1}, @var{rho})
1225 Bivariate normal distribution of two standard normal variables with
1226 correlation coefficient @var{rho}. Two variates @var{x0} and @var{x1}
1227 must be provided. Constraints: 0 <= @var{rho} <= 1, 0 <= @var{p} <= 1.
1230 @deftypefn {Function} {} PDF.CAUCHY (@var{x}, @var{a}, @var{b})
1231 @deftypefnx {Function} {} CDF.CAUCHY (@var{x}, @var{a}, @var{b})
1232 @deftypefnx {Function} {} IDF.CAUCHY (@var{p}, @var{a}, @var{b})
1233 @deftypefnx {Function} {} RV.CAUCHY (@var{a}, @var{b})
1234 Cauchy distribution with location parameter @var{a} and scale
1235 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1238 @c @deftypefn {Function} {} PDF.CHISQ (@var{x}, @var{df})
1239 @deftypefn {Function} {} CDF.CHISQ (@var{x}, @var{df})
1240 @deftypefnx {Function} {} SIG.CHISQ (@var{x}, @var{df})
1241 @deftypefnx {Function} {} IDF.CHISQ (@var{p}, @var{df})
1242 @deftypefnx {Function} {} RV.CHISQ (@var{df})
1243 @c @deftypefnx {Function} {} NPDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1244 @deftypefnx {Function} {} NCDF.CHISQ (@var{x}, @var{df}, @var{lambda})
1245 Chi-squared distribution with @var{df} degrees of freedom. The
1246 noncentral distribution takes an additional parameter @var{lambda}.
1247 Constraints: @var{df} > 0, @var{lambda} > 0, @var{x} >= 0, 0 <=
1251 @deftypefn {Function} {} PDF.EXP (@var{x}, @var{a})
1252 @deftypefnx {Function} {} CDF.EXP (@var{x}, @var{a})
1253 @deftypefnx {Function} {} IDF.EXP (@var{p}, @var{a})
1254 @deftypefnx {Function} {} RV.EXP (@var{a})
1255 Exponential distribution with scale parameter @var{a}. The inverse of
1256 @var{a} represents the rate of decay. Constraints: @var{a} > 0,
1257 @var{x} >= 0, 0 <= @var{p} < 1.
1260 @deftypefn {Function} {} PDF.XPOWER (@var{x}, @var{a}, @var{b})
1261 @deftypefnx {Function} {} RV.XPOWER (@var{a}, @var{b})
1262 Exponential power distribution with positive scale parameter @var{a}
1263 and nonnegative power parameter @var{b}. Constraints: @var{a} > 0,
1264 @var{b} >= 0, @var{x} >= 0, 0 <= @var{p} <= 1. This distribution is a
1268 @deftypefn {Function} {} PDF.F (@var{x}, @var{df1}, @var{df2})
1269 @deftypefnx {Function} {} CDF.F (@var{x}, @var{df1}, @var{df2})
1270 @deftypefnx {Function} {} SIG.F (@var{x}, @var{df1}, @var{df2})
1271 @deftypefnx {Function} {} IDF.F (@var{p}, @var{df1}, @var{df2})
1272 @deftypefnx {Function} {} RV.F (@var{df1}, @var{df2})
1273 @c @deftypefnx {Function} {} NPDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1274 @c @deftypefnx {Function} {} NCDF.F (@var{x}, @var{df1}, @var{df2}, @var{lambda})
1275 F-distribution of two chi-squared deviates with @var{df1} and
1276 @var{df2} degrees of freedom. The noncentral distribution takes an
1277 additional parameter @var{lambda}. Constraints: @var{df1} > 0,
1278 @var{df2} > 0, @var{lambda} >= 0, @var{x} >= 0, 0 <= @var{p} < 1.
1281 @deftypefn {Function} {} PDF.GAMMA (@var{x}, @var{a}, @var{b})
1282 @deftypefnx {Function} {} CDF.GAMMA (@var{x}, @var{a}, @var{b})
1283 @deftypefnx {Function} {} IDF.GAMMA (@var{p}, @var{a}, @var{b})
1284 @deftypefnx {Function} {} RV.GAMMA (@var{a}, @var{b})
1285 Gamma distribution with shape parameter @var{a} and scale parameter
1286 @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <=
1290 @c @deftypefn {Function} {} PDF.HALFNRM (@var{x}, @var{a}, @var{b})
1291 @c @deftypefnx {Function} {} CDF.HALFNRM (@var{x}, @var{a}, @var{b})
1292 @c @deftypefnx {Function} {} IDF.HALFNRM (@var{p}, @var{a}, @var{b})
1293 @c @deftypefnx {Function} {} RV.HALFNRM (@var{a}, @var{b})
1294 @c Half-normal distribution with location parameter @var{a} and shape
1295 @c parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1298 @c @deftypefn {Function} {} PDF.IGAUSS (@var{x}, @var{a}, @var{b})
1299 @c @deftypefnx {Function} {} CDF.IGAUSS (@var{x}, @var{a}, @var{b})
1300 @c @deftypefnx {Function} {} IDF.IGAUSS (@var{p}, @var{a}, @var{b})
1301 @c @deftypefnx {Function} {} RV.IGAUSS (@var{a}, @var{b})
1302 @c Inverse Gaussian distribution with parameters @var{a} and @var{b}.
1303 @c Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <= @var{p} < 1.
1306 @deftypefn {Function} {} PDF.LANDAU (@var{x})
1307 @deftypefnx {Function} {} RV.LANDAU ()
1308 Landau distribution.
1311 @deftypefn {Function} {} PDF.LAPLACE (@var{x}, @var{a}, @var{b})
1312 @deftypefnx {Function} {} CDF.LAPLACE (@var{x}, @var{a}, @var{b})
1313 @deftypefnx {Function} {} IDF.LAPLACE (@var{p}, @var{a}, @var{b})
1314 @deftypefnx {Function} {} RV.LAPLACE (@var{a}, @var{b})
1315 Laplace distribution with location parameter @var{a} and scale
1316 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1319 @deftypefn {Function} {} RV.LEVY (@var{c}, @var{alpha})
1320 Levy symmetric alpha-stable distribution with scale @var{c} and
1321 exponent @var{alpha}. Constraints: 0 < @var{alpha} <= 2.
1324 @deftypefn {Function} {} RV.LVSKEW (@var{c}, @var{alpha}, @var{beta})
1325 Levy skew alpha-stable distribution with scale @var{c}, exponent
1326 @var{alpha}, and skewness parameter @var{beta}. Constraints: 0 <
1327 @var{alpha} <= 2, -1 <= @var{beta} <= 1.
1330 @deftypefn {Function} {} PDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1331 @deftypefnx {Function} {} CDF.LOGISTIC (@var{x}, @var{a}, @var{b})
1332 @deftypefnx {Function} {} IDF.LOGISTIC (@var{p}, @var{a}, @var{b})
1333 @deftypefnx {Function} {} RV.LOGISTIC (@var{a}, @var{b})
1334 Logistic distribution with location parameter @var{a} and scale
1335 parameter @var{b}. Constraints: @var{b} > 0, 0 < @var{p} < 1.
1338 @deftypefn {Function} {} PDF.LNORMAL (@var{x}, @var{a}, @var{b})
1339 @deftypefnx {Function} {} CDF.LNORMAL (@var{x}, @var{a}, @var{b})
1340 @deftypefnx {Function} {} IDF.LNORMAL (@var{p}, @var{a}, @var{b})
1341 @deftypefnx {Function} {} RV.LNORMAL (@var{a}, @var{b})
1342 Lognormal distribution with parameters @var{a} and @var{b}.
1343 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1346 @deftypefn {Function} {} PDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1347 @deftypefnx {Function} {} CDF.NORMAL (@var{x}, @var{mu}, @var{sigma})
1348 @deftypefnx {Function} {} IDF.NORMAL (@var{p}, @var{mu}, @var{sigma})
1349 @deftypefnx {Function} {} RV.NORMAL (@var{mu}, @var{sigma})
1350 Normal distribution with mean @var{mu} and standard deviation
1351 @var{sigma}. Constraints: @var{b} > 0, 0 < @var{p} < 1. Three
1352 additional functions are available as shorthand:
1354 @deftypefn {Function} {} CDFNORM (@var{x})
1355 Equivalent to CDF.NORMAL(@var{x}, 0, 1).
1358 @deftypefn {Function} {} PROBIT (@var{p})
1359 Equivalent to IDF.NORMAL(@var{p}, 0, 1).
1362 @deftypefn {Function} {} NORMAL (@var{sigma})
1363 Equivalent to RV.NORMAL(0, @var{sigma}).
1367 @deftypefn {Function} {} PDF.NTAIL (@var{x}, @var{a}, @var{sigma})
1368 @deftypefnx {Function} {} RV.NTAIL (@var{a}, @var{sigma})
1369 Normal tail distribution with lower limit @var{a} and standard
1370 deviation @var{sigma}. This distribution is a @pspp{} extension.
1371 Constraints: @var{a} > 0, @var{x} > @var{a}, 0 < @var{p} < 1.
1374 @deftypefn {Function} {} PDF.PARETO (@var{x}, @var{a}, @var{b})
1375 @deftypefnx {Function} {} CDF.PARETO (@var{x}, @var{a}, @var{b})
1376 @deftypefnx {Function} {} IDF.PARETO (@var{p}, @var{a}, @var{b})
1377 @deftypefnx {Function} {} RV.PARETO (@var{a}, @var{b})
1378 Pareto distribution with threshold parameter @var{a} and shape
1379 parameter @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} >=
1380 @var{a}, 0 <= @var{p} < 1.
1383 @deftypefn {Function} {} PDF.RAYLEIGH (@var{x}, @var{sigma})
1384 @deftypefnx {Function} {} CDF.RAYLEIGH (@var{x}, @var{sigma})
1385 @deftypefnx {Function} {} IDF.RAYLEIGH (@var{p}, @var{sigma})
1386 @deftypefnx {Function} {} RV.RAYLEIGH (@var{sigma})
1387 Rayleigh distribution with scale parameter @var{sigma}. This
1388 distribution is a @pspp{} extension. Constraints: @var{sigma} > 0,
1392 @deftypefn {Function} {} PDF.RTAIL (@var{x}, @var{a}, @var{sigma})
1393 @deftypefnx {Function} {} RV.RTAIL (@var{a}, @var{sigma})
1394 Rayleigh tail distribution with lower limit @var{a} and scale
1395 parameter @var{sigma}. This distribution is a @pspp{} extension.
1396 Constraints: @var{a} > 0, @var{sigma} > 0, @var{x} > @var{a}.
1399 @c @deftypefn {Function} {} CDF.SMOD (@var{x}, @var{a}, @var{b})
1400 @c @deftypefnx {Function} {} IDF.SMOD (@var{p}, @var{a}, @var{b})
1401 @c Studentized maximum modulus distribution with parameters @var{a} and
1402 @c @var{b}. Constraints: @var{a} > 0, @var{b} > 0, @var{x} > 0, 0 <=
1406 @c @deftypefn {Function} {} CDF.SRANGE (@var{x}, @var{a}, @var{b})
1407 @c @deftypefnx {Function} {} IDF.SRANGE (@var{p}, @var{a}, @var{b})
1408 @c Studentized range distribution with parameters @var{a} and @var{b}.
1409 @c Constraints: @var{a} >= 1, @var{b} >= 1, @var{x} > 0, 0 <= @var{p} <
1413 @deftypefn {Function} {} PDF.T (@var{x}, @var{df})
1414 @deftypefnx {Function} {} CDF.T (@var{x}, @var{df})
1415 @deftypefnx {Function} {} IDF.T (@var{p}, @var{df})
1416 @deftypefnx {Function} {} RV.T (@var{df})
1417 @c @deftypefnx {Function} {} NPDF.T (@var{x}, @var{df}, @var{lambda})
1418 @c @deftypefnx {Function} {} NCDF.T (@var{x}, @var{df}, @var{lambda})
1419 T-distribution with @var{df} degrees of freedom. The noncentral
1420 distribution takes an additional parameter @var{lambda}. Constraints:
1421 @var{df} > 0, 0 < @var{p} < 1.
1424 @deftypefn {Function} {} PDF.T1G (@var{x}, @var{a}, @var{b})
1425 @deftypefnx {Function} {} CDF.T1G (@var{x}, @var{a}, @var{b})
1426 @deftypefnx {Function} {} IDF.T1G (@var{p}, @var{a}, @var{b})
1427 Type-1 Gumbel distribution with parameters @var{a} and @var{b}. This
1428 distribution is a @pspp{} extension. Constraints: 0 < @var{p} < 1.
1431 @deftypefn {Function} {} PDF.T2G (@var{x}, @var{a}, @var{b})
1432 @deftypefnx {Function} {} CDF.T2G (@var{x}, @var{a}, @var{b})
1433 @deftypefnx {Function} {} IDF.T2G (@var{p}, @var{a}, @var{b})
1434 Type-2 Gumbel distribution with parameters @var{a} and @var{b}. This
1435 distribution is a @pspp{} extension. Constraints: @var{x} > 0, 0 <
1439 @deftypefn {Function} {} PDF.UNIFORM (@var{x}, @var{a}, @var{b})
1440 @deftypefnx {Function} {} CDF.UNIFORM (@var{x}, @var{a}, @var{b})
1441 @deftypefnx {Function} {} IDF.UNIFORM (@var{p}, @var{a}, @var{b})
1442 @deftypefnx {Function} {} RV.UNIFORM (@var{a}, @var{b})
1443 Uniform distribution with parameters @var{a} and @var{b}.
1444 Constraints: @var{a} <= @var{x} <= @var{b}, 0 <= @var{p} <= 1. An
1445 additional function is available as shorthand:
1447 @deftypefn {Function} {} UNIFORM (@var{b})
1448 Equivalent to RV.UNIFORM(0, @var{b}).
1452 @deftypefn {Function} {} PDF.WEIBULL (@var{x}, @var{a}, @var{b})
1453 @deftypefnx {Function} {} CDF.WEIBULL (@var{x}, @var{a}, @var{b})
1454 @deftypefnx {Function} {} IDF.WEIBULL (@var{p}, @var{a}, @var{b})
1455 @deftypefnx {Function} {} RV.WEIBULL (@var{a}, @var{b})
1456 Weibull distribution with parameters @var{a} and @var{b}.
1457 Constraints: @var{a} > 0, @var{b} > 0, @var{x} >= 0, 0 <= @var{p} < 1.
1460 @node Discrete Distributions
1461 @subsubsection Discrete Distributions
1463 The following discrete distributions are available:
1465 @deftypefn {Function} {} PDF.BERNOULLI (@var{x})
1466 @deftypefnx {Function} {} CDF.BERNOULLI (@var{x}, @var{p})
1467 @deftypefnx {Function} {} RV.BERNOULLI (@var{p})
1468 Bernoulli distribution with probability of success @var{p}.
1469 Constraints: @var{x} = 0 or 1, 0 <= @var{p} <= 1.
1472 @deftypefn {Function} {} PDF.BINOM (@var{x}, @var{n}, @var{p})
1473 @deftypefnx {Function} {} CDF.BINOM (@var{x}, @var{n}, @var{p})
1474 @deftypefnx {Function} {} RV.BINOM (@var{n}, @var{p})
1475 Binomial distribution with @var{n} trials and probability of success
1476 @var{p}. Constraints: integer @var{n} > 0, 0 <= @var{p} <= 1, integer
1480 @deftypefn {Function} {} PDF.GEOM (@var{x}, @var{n}, @var{p})
1481 @deftypefnx {Function} {} CDF.GEOM (@var{x}, @var{n}, @var{p})
1482 @deftypefnx {Function} {} RV.GEOM (@var{n}, @var{p})
1483 Geometric distribution with probability of success @var{p}.
1484 Constraints: 0 <= @var{p} <= 1, integer @var{x} > 0.
1487 @deftypefn {Function} {} PDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1488 @deftypefnx {Function} {} CDF.HYPER (@var{x}, @var{a}, @var{b}, @var{c})
1489 @deftypefnx {Function} {} RV.HYPER (@var{a}, @var{b}, @var{c})
1490 Hypergeometric distribution when @var{b} objects out of @var{a} are
1491 drawn and @var{c} of the available objects are distinctive.
1492 Constraints: integer @var{a} > 0, integer @var{b} <= @var{a}, integer
1493 @var{c} <= @var{a}, integer @var{x} >= 0.
1496 @deftypefn {Function} {} PDF.LOG (@var{x}, @var{p})
1497 @deftypefnx {Function} {} RV.LOG (@var{p})
1498 Logarithmic distribution with probability parameter @var{p}.
1499 Constraints: 0 <= @var{p} < 1, @var{x} >= 1.
1502 @deftypefn {Function} {} PDF.NEGBIN (@var{x}, @var{n}, @var{p})
1503 @deftypefnx {Function} {} CDF.NEGBIN (@var{x}, @var{n}, @var{p})
1504 @deftypefnx {Function} {} RV.NEGBIN (@var{n}, @var{p})
1505 Negative binomial distribution with number of successes parameter
1506 @var{n} and probability of success parameter @var{p}. Constraints:
1507 integer @var{n} >= 0, 0 < @var{p} <= 1, integer @var{x} >= 1.
1510 @deftypefn {Function} {} PDF.POISSON (@var{x}, @var{mu})
1511 @deftypefnx {Function} {} CDF.POISSON (@var{x}, @var{mu})
1512 @deftypefnx {Function} {} RV.POISSON (@var{mu})
1513 Poisson distribution with mean @var{mu}. Constraints: @var{mu} > 0,
1514 integer @var{x} >= 0.
1517 @node Order of Operations
1518 @section Operator Precedence
1519 @cindex operator precedence
1520 @cindex precedence, operator
1521 @cindex order of operations
1522 @cindex operations, order of
1524 The following table describes operator precedence. Smaller-numbered
1525 levels in the table have higher precedence. Within a level,
1526 operations are always performed from left to right. The first
1527 occurrence of @samp{-} represents unary negation, the second binary
1542 @code{EQ GE GT LE LT NE}